Я использую Node env, где я делаю request.get, чтобы извлечь файл из URL-адреса, а затем отправить его на Stripe. Я получаю ошибку 141, что мой файл недействителен. Существует промежуточный шаг между извлечением файла и его отправкой, который мне не хватает, но не уверен, что. Раньше я использовал fs.readFileSync для локального файла, но больше не использую его, так как теперь я извлекаю файл с сервера.Node Stripe file upload from 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.
}
});
Вот ошибка, я получаю от 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
Я думаю, вам нужно изменить свое mimetime как 'type: image/png' вместо текущего типа:' 'application/octet-stream'' –