marmot-client
Advanced tools
Comparing version 1.4.0 to 1.4.1-alpha
@@ -10,2 +10,3 @@ "use strict"; | ||
const Debug = require("debug"); | ||
const mime = require("mime"); | ||
const debug = Debug('marmot-client:marmot'); | ||
@@ -133,2 +134,3 @@ const roa_1 = require("./roa"); | ||
const { uploadParams, uploadOrigin, objectUrl } = data; | ||
const contentType = mime.getType(fileType); | ||
// 2. 上传文件 | ||
@@ -143,4 +145,10 @@ const formData = new FormData(); | ||
if (Buffer.isBuffer(file)) { | ||
assert(storagePath, 'param storagePath is required for buffer'); | ||
formData.append('file', file, path.basename(storagePath)); | ||
if (storagePath) { | ||
formData.append('file', file, path.basename(storagePath)); | ||
} | ||
else { | ||
formData.append('file', file, { | ||
contentType, | ||
}); | ||
} | ||
} | ||
@@ -176,2 +184,2 @@ else if (typeof file === 'string') { | ||
exports.default = MarmotClient; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFybW90LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL21hcm1vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5QkFBeUI7QUFDekIsNkJBQTZCO0FBQzdCLGtDQUFrQztBQUNsQyxpQ0FBaUM7QUFDakMsc0NBQXNDO0FBQ3RDLCtCQUErQjtBQUMvQixNQUFNLEtBQUssR0FBRyxLQUFLLENBQUMsc0JBQXNCLENBQUMsQ0FBQztBQUU1QywrQkFBOEI7QUFXOUIsSUFBWSxHQUtYO0FBTEQsV0FBWSxHQUFHO0lBQ2Isa0JBQVcsQ0FBQTtJQUNYLG9CQUFhLENBQUE7SUFDYixrQkFBVyxDQUFBO0lBQ1gsb0JBQWEsQ0FBQTtBQUNmLENBQUMsRUFMVyxHQUFHLEdBQUgsV0FBRyxLQUFILFdBQUcsUUFLZDtBQUVELElBQVksT0FHWDtBQUhELFdBQVksT0FBTztJQUNqQiw4QkFBbUIsQ0FBQTtJQU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0IsR0FBRyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUM7U0FDeEQ7UUFFRCxPQUFPLEVBQUUsU0FBUyxFQUFFLENBQUM7SUFDdkIsQ0FBQztDQUNGO0FBRUQsa0JBQWUsWUFBWSxDQUFDIn0= |
{ | ||
"name": "marmot-client", | ||
"version": "1.4.0", | ||
"version": "1.4.1-alpha", | ||
"description": "Marmot client.", | ||
@@ -16,2 +16,3 @@ "keywords": [ | ||
"form-data": "^3.0.0", | ||
"mime": "^3.0.0", | ||
"urllib": "^2.32.0" | ||
@@ -21,2 +22,3 @@ }, | ||
"@types/debug": "^4.1.5", | ||
"@types/mime": "^2.0.3", | ||
"@types/mocha": "^8.0.1", | ||
@@ -23,0 +25,0 @@ "@types/node": "^14.0.27", |
@@ -23,1 +23,46 @@ ### 调用 Marmot OpenAPI 客户端 | ||
``` | ||
### upload | ||
#### 服务端一步上传 | ||
##### 使用 | ||
```typescript | ||
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扩展参数,会原封不动的传给[阿里云](https://help.aliyun.com/document_detail/31988.html#section-0lu-03w-2z6)或者[aws](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTForms.html) | ||
##### 响应 | ||
名称|类型|样例|描述 | ||
-|-|-|- | ||
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 及以上才能使用。 |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
31214
385
67
4
21
2
+ Addedmime@^3.0.0
+ Addedmime@3.0.0(transitive)