npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

marmot-client

v1.4.2

Published

Marmot client.

Downloads

137

Readme

调用 Marmot OpenAPI 客户端

例子 example

$ npm i -g ts-node
$ ts-node example/upload.ts

支持的接口

  • 查询应用信息
  • 上传文件
  • 调用异步任务
  • 加/解密

Publish

$ npm version patch
$ npm publish

upload

服务端一步上传

使用
import * as fs from 'fs';
import * as path from 'path';
import { MarmotClient } from 'marmot-client';

const client = new MarmotClient({
  accessKeyId: 'YOUR_ACCESS_KEY_ID',
  accessKeySecret: 'YOUR_ACCESS_KEY_SECRET',
  endpoint: 'http://kapi.marmot-cloud.com',
  apiVersion: '1.0.0',
});
// 1.1 上传公共文件,默认随机路径
async function uploadACLPublic() {
  const result = await client.upload({
    file: path.join(__dirname, 'sample.txt'),
    fileType: 'txt'
  });
  console.log('上传公共文件,默认随机路径', result);
}
参数

名称|类型|必填|默认值|样例|描述 -|-|-|-|-|- fileType|string|是||txt|文件后缀名,需要和实际上传的文件类型一致 file| string\|Buffer\|fs.ReadStream|是||path.join(__dirname, 'sample.txt')|需要上传的文件 storagePath|string|否||my-sample.txt|可以自定义上传路径,默认上传到 uuid 随机路径 contentDisposition|string|否|默认是文件名|attachment; filename=${encodeURIComponent('中文.xls')} |指定 Content-Disposition,例如 Content-Disposition: attachment; filename="filename.jpg" 点击链接下载文件而非打开文件 env|string|否|不传默认是ak申请时默认的bucket|DEV|DEV DEV、TEST、PRE、PROD,申请AK时如果自定义存储服务时可以指定存储Bucket的环境标识,传入该字段可以对该租户下的bucket进行按env筛选出要上传的目标bucket acl|string|否|public-read|private|private、public-read 标识返回的objectUrl是否是私有 ...||否|||阿里云或者aws扩展参数,会原封不动的传给阿里云或者aws

响应

名称|类型|样例|描述 -|-|-|- objectUrl|string|http://cdn.marmot-cloud.com/storage/test-file-DEVELOPMENT/2022/07/08/4d33492e-7746-4d73-a747-f5fd27f28348.txt|上传后的文件地址

注意

一步上传的方式仅提供于纯服务端上传,如果你的应用有前端页面,我们强烈推荐你使用上述的两步接入的方法,需要 marmot-client 版本在 1.4.0 及以上才能使用。