Error uploading to S3 using read streams and putObject
See original GitHub issueBug report
I was trying to use the S3 adapter to upload files in the admin api using the File field type. When attempting to upload the file I would get a ‘nested errors’ message. There wouldn’t be anything in the CLI log where the app was running. I had make my own version of the adapter in a stand-alone project locally to debug this. Essentially, the file is getting a read stream and the putObject
method of the AWS SDK expects a binary string. This can be resolved by using the upload
method as it is smart and can handle read streams. I can prepare a PR if you would like.
To Reproduce
Steps to reproduce the behaviour. Please provide code snippets or a repository:
- Setup S3 file adapter like demonstrated in the documentation.
- Try to upload file
- Error
Expected behaviour
Uploading a file should work
Screenshots
System information
- OS: Linux (Docker)
Additional context
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
S3.putObject only accepts streams that it can determine the ...
According to https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property the Body element can be a ReadableStream , ...
Read more >node.js - Pipe a stream to s3.upload() - Stack Overflow
Wrap the S3 upload() function with the node.js stream.PassThrough() stream. Here's an example: inputStream .pipe(uploadFromStream(s3)); ...
Read more >Upload an object to an Amazon S3 bucket using an AWS SDK
Upload a file from local storage to a bucket. Upload the contents of a Swift Data object to a bucket. For API details,...
Read more >Programmatically Stream (Upload) Large Files to Amazon S3
It's also possible to pipe a data stream to it in order to upload very large objects. To do this, simply wrap the...
Read more >Uploading large files to S3 using streams
I'll use my admin credentials to run the code from my computer. The minimum permission you'll need is PutObject , which is a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@LiamAttClarke #2249 is exactly what I did to fix it.
According to the docs,
s3.putObject
accepts “Buffer, Typed Array, Blob, String, ReadableStream”.https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property
That said, I agree that the
s3.upload
method would be better.