Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marmot-client

Package Overview
Dependencies
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marmot-client

Marmot client.

  • 1.4.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

调用 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);
}
参数
名称类型必填默认值样例描述
fileTypestringtxt文件后缀名,需要和实际上传的文件类型一致
filestring|Buffer|fs.ReadStreampath.join(__dirname, 'sample.txt')需要上传的文件
storagePathstringmy-sample.txt可以自定义上传路径,默认上传到 uuid 随机路径
contentDispositionstring默认是文件名attachment; filename=${encodeURIComponent('中文.xls')}指定 Content-Disposition,例如 Content-Disposition: attachment; filename="filename.jpg" 点击链接下载文件而非打开文件
envstring不传默认是ak申请时默认的bucketDEVDEV DEV、TEST、PRE、PROD,申请AK时如果自定义存储服务时可以指定存储Bucket的环境标识,传入该字段可以对该租户下的bucket进行按env筛选出要上传的目标bucket
aclstringpublic-readprivateprivate、public-read 标识返回的objectUrl是否是私有
...阿里云或者aws扩展参数,会原封不动的传给阿里云或者aws
响应
名称类型样例描述
objectUrlstringhttp://cdn.marmot-cloud.com/storage/test-file-DEVELOPMENT/2022/07/08/4d33492e-7746-4d73-a747-f5fd27f28348.txt上传后的文件地址
注意

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

Keywords

FAQs

Package last updated on 17 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc