0
我正在使用一個Node env,我正在做一個request.get來從一個url中檢索一個文件然後發送給Stripe。我收到一個141錯誤,說我的文件無效。在檢索文件和發送文件之間存在中間步驟,但我不知道哪一步。我過去使用fs.readFileSync作爲本地文件,但現在不再使用它了,因爲我現在從服務器檢索文件。節點從request.get上傳條帶文件body res
Request.get(req.params.url, function (error, response, body) {
if (!error && response.statusCode == 200) {
Stripe.fileUploads.create({
purpose: 'identity_document',
file: {
data: body, // missing a step before sending it off
name: 'file.png',
type: 'application/octet-stream'
}
}, function(err, fileUpload) {
if (err) {
console.error(JSON.stringify(err));
return res.error(err);
}
console.log(JSON.stringify(fileUpload));
});
// Continue with your processing here.
}
});
下面是我從條紋
code=141, type=StripeInvalidRequestError, rawType=invalid_request_error, code=undefined, param=file, message=We don't currently support that file type. Try uploading a file with one of the following mimetypes: image/jpeg, image/png, detail=undefined, type=invalid_request_error, message=We don't currently support that file type. Try uploading a file with one of the following mimetypes: image/jpeg, image/png
我想你需要改變你的mimetime,'type:image/png'而不是現在的類型:''application/octet-stream'' –