分段上传后文件内容不正确
Incorrect file content after multipart upload
我正在尝试使用 Filepicker API 和 request.js 模块将文件上传到 S3。
content = "ABCDEF"
options =
url: 'https://www.filepicker.io/api/store/S3'
preambleCRLF: true # tried also with false
postambleCRLF: true # tried also with false
qs:
key: 'XXX'
store: 'S3'
mimetype: 'text/csv'
path: 'some-path.csv'
container: 'my-bucket'
access: 'public'
multipart: [
{
body: content
}
]
method: 'post'
request options, (err, res, body) ->
# 200 OK
它通常有效,但上传的文件内容如下所示:
--6f63ec28-40de-425c-86d5-36f0befcec4a
ABCDEF
--6f63ec28-40de-425c-86d5-36f0befcec4a--
我做错了什么?
此请求的主要问题是您将多部分选项放入查询字符串参数中。对我有用的请求是:
request = require("request");
content = "ABCDEF";
options = {
url: 'https://www.filepicker.io/api/store/S3',
preambleCRLF: true,
postambleCRLF: true,
multipart: [
{
body: content
}
],
method: 'post',
qs: {
key: 'APIKEY',
store: 'S3',
mimetype: 'text/csv',
path: 'some-path.csv',
access: 'public',
}
};
request(options, function(err, res, body) {
console.log(res.statusCode);
console.log(body);
});
我正在尝试使用 Filepicker API 和 request.js 模块将文件上传到 S3。
content = "ABCDEF"
options =
url: 'https://www.filepicker.io/api/store/S3'
preambleCRLF: true # tried also with false
postambleCRLF: true # tried also with false
qs:
key: 'XXX'
store: 'S3'
mimetype: 'text/csv'
path: 'some-path.csv'
container: 'my-bucket'
access: 'public'
multipart: [
{
body: content
}
]
method: 'post'
request options, (err, res, body) ->
# 200 OK
它通常有效,但上传的文件内容如下所示:
--6f63ec28-40de-425c-86d5-36f0befcec4a
ABCDEF
--6f63ec28-40de-425c-86d5-36f0befcec4a--
我做错了什么?
此请求的主要问题是您将多部分选项放入查询字符串参数中。对我有用的请求是:
request = require("request");
content = "ABCDEF";
options = {
url: 'https://www.filepicker.io/api/store/S3',
preambleCRLF: true,
postambleCRLF: true,
multipart: [
{
body: content
}
],
method: 'post',
qs: {
key: 'APIKEY',
store: 'S3',
mimetype: 'text/csv',
path: 'some-path.csv',
access: 'public',
}
};
request(options, function(err, res, body) {
console.log(res.statusCode);
console.log(body);
});