Closed steel-hyuk closed 11 months ago
I am trying to upload an image using @aws-sdk/client-s3 and @aws-sdk/lib-storage.
It is uploaded to s3, but when you look at the uploaded image, the bottom part appears gray as in the image below.
What can i try to solve this problem?
"@aws-sdk/client-s3": "^3.470.0", "@aws-sdk/lib-storage": "^3.470.0",
Node.js
16.20.2
import { Resolver, Mutation, Args } from '@nestjs/graphql'; import { FileUpload, GraphQLUpload } from 'graphql-upload'; @Mutation(() => ImageUploadResult) async uploadImage( @Args('input') input: ImageUploadInput, @Args('file', { name: 'file', type: () => GraphQLUpload }) file: FileUpload ): Promise<ImageUploadResult> { // const uploadDir = './uploads'; // if (!fs.existsSync(uploadDir)) { // fs.mkdirSync(uploadDir); // } // const randomN = Math.floor(Math.random() * 1000); // const filePath = path.join(uploadDir, `${randomN}${file.filename}`); // const fileStream = fs.createWriteStream(filePath); // file.createReadStream().pipe(fileStream); const upload = new Upload({ client: new S3Client({ region: mys3region, credentials: { accessKeyId: mys3accessKeyId, secretAccessKey: mys3secretAccessKey } });, params: { Bucket: mys3bucketName, Key: file.filename, Body: file.createReadStream() } }); try { const result = await upload.done(); return { imageUrl: result['Location'] }; } catch (error) { throw new Error(ErrorMessage.FailedToUploadImage); } }
No error occurs.
I hope i see a normal image
No response
If i save the file in the local environment and check, it is normal.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Checkboxes for prior research
Describe the bug
I am trying to upload an image using @aws-sdk/client-s3 and @aws-sdk/lib-storage.
It is uploaded to s3, but when you look at the uploaded image, the bottom part appears gray as in the image below.
What can i try to solve this problem?
SDK version number
"@aws-sdk/client-s3": "^3.470.0", "@aws-sdk/lib-storage": "^3.470.0",
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
16.20.2
Reproduction Steps
Observed Behavior
No error occurs.
Expected Behavior
I hope i see a normal image
Possible Solution
No response
Additional Information/Context
If i save the file in the local environment and check, it is normal.