Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
marmot-client
Advanced tools
例子 example
$ npm i -g ts-node
$ ts-node example/upload.ts
支持的接口
$ npm version patch
$ npm publish
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 及以上才能使用。
FAQs
Marmot client.
The npm package marmot-client receives a total of 15 weekly downloads. As such, marmot-client popularity was classified as not popular.
We found that marmot-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.