[英]Piping a multipart file upload to a S3 bucket
I would like to pipe a file upload that I receive from a multipart request to a S3 bucket using express
and aws-sdk
.我想 pipe 使用express
和aws-sdk
从多部分请求到 S3 存储桶的文件上传。
I use the upload
function, it can use a readable stream for the Body
parameter.我使用upload
function,它可以使用可读的 stream 作为Body
参数。
await s3Client
.upload({
Bucket: 'some_bucket',
Key: `records/recordXYZ`,
Body: req,
ContentType: 'audio/x-wav,
})
.promise();
req
is from express. req
来自快递。 The request is correctly parsed, the issue is that in the created file in S3 I retrieve some fields from the multipart request that I don't want into.请求已正确解析,问题是在 S3 中创建的文件中,我从多部分请求中检索了一些我不想进入的字段。 The file is unreadable.该文件不可读。
What is inside the file in S3: S3中的文件里面有什么:
--JP2kMlzhqj2uAUdy4al132WFLRexf1
Content-Disposition: form-data; name="aFile"; filename="test.wav"
Content-Type: audio/wav
Content-Transfer-Encoding: binary
RIFF| WAVEfmt ...
Want I need is only:我需要的只是:
RIFF| WAVEfmt ...
Got it working with multer-s3
: https://github.com/badunk/multer-s3让它与multer-s3
一起使用: https://github.com/badunk/multer-s3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.