Open janhesters opened 1 year ago
Okay, I fixed it like this, so you need to install @aws-sdk/lib-storage
and @aws-sdk/client-s3
:
import { DeleteObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
export const uploadStream = ({ Key }: Pick<PutObjectCommandInput, 'Key'>) => {
const client = new S3Client({ region: S3_STORAGE_REGION });
const pass = new PassThrough();
return {
writeStream: pass,
promise: new Upload({
client,
params: {
Body: pass,
Bucket: S3_STORAGE_BUCKET,
Key,
},
}).done(),
};
};
Then you'll also have to grab the location, if the request was successful in uploadStreamToS3()
:
const file = await stream.promise;
if ('Location' in file) {
return file.Location;
}
throw new Error('Upload to S3 aborted');
Made a PR to add an example for the new SDK version here: https://github.com/remix-run/examples/pull/164
This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed.
This issue has been automatically closed because we didn't hear anything from the original author after the previous notice.
Recently, the AWS SDK v3 has been released and its now the recommended way to interact with AWS.
I tried to upgrade the S3 example myself, like this:
But it doesn't work because an error is thrown:
by this line:
in
uploadStreamToS3()
.I'm not skilled in S3, so I have no idea how to fix this.