I am trying to upload file to S3 using Filepicker API and request.js module.
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
It generally works however uploaded file content looks like this:
--6f63ec28-40de-425c-86d5-36f0befcec4a
ABCDEF
--6f63ec28-40de-425c-86d5-36f0befcec4a--
What am I doing wrong?
The main problem with this request was you have put multipart option inside querystring parameter. The request that worked for me was:
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);
});