我正在使用Node env,我正在发出请求。从网址中检索文件然后将其发送到Stripe。我得到141错误,我的文件无效。检索文件和发送它之间有中间步骤,我错过了但不确定哪个。我曾经使用fs.readFileSync作为本地文件但不再使用它,因为我现在正在从服务器检索文件。
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.
}
});
以下是我从Stripe
获得的错误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
答案 0 :(得分:0)
将file.type
从application/octet-stream
更改为image/png
。