-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Location field in Upload utility in lib-storage is wrong #4109
Comments
Hi @yoniheib , Can you include your code? Thanks, |
Sure: import {
S3Client,
type CompleteMultipartUploadCommandOutput
} from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
const s3 = new S3Client({ region: 'us-west-1' });
const S3DefaultUploadParams = {
Bucket: process.env.AWS_S3_BUCKET as string,
ACL: 'public-read',
};
export async function uploadFileToS3()
{
const params = {
...S3DefaultUploadParams,
Key: 'test',
Body: 'TEST',
};
const upload = new Upload({ client: s3, params});
const result = await upload.done() as CompleteMultipartUploadCommandOutput;
console.log(result.Location);
return result.Location;
}; When I run this the Location value is: |
Hi @yoniheib , I'm able to confirm that this is incorrect behavior. Will assign it to the dev team to fix. Thanks! |
I also just ran into the same thing on 3.198.0
|
not gonna pretend to be qualified on the full implications of the setting but // define a shared client for the various functions
const s3Client = new S3Client({
...otherConfig
forcePathStyle: true,
}) result:
https://s3.us-east-2.amazonaws.com/kbi-dev-photo-uploads/uploads/profileImages/1666923440713. The URL format is a bit different than I'm used to but it renders my image so yeah seems like a temporary workaround. |
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
The calculated Location field (based on Bucket and endpoint) is wrong.
In this line:
aws-sdk-js-v3/lib/lib-storage/src/Upload.ts
Line 158 in d600213
The locationBucket is appended with endpoint.hostname, but endpoint.hostname already contains the bucket.
This causes the locationBucket to appear twice and creates an invalid URI.
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node.JS 16
Reproduction Steps
I used the example for the lib-storage library and the Location field was wrong.
Observed Behavior
For bucket name: test-bucket-staging
Location field is:
https://test-bucket-staging.test-bucket-staging.s3.us-west-1.amazonaws.com/test-image.jpeg
Expected Behavior
For bucket name: test-bucket-staging
I would expect the field to be:
https://test-bucket-staging.s3.us-west-1.amazonaws.com/test-image.jpeg
Possible Solution
I'm assuming that only endpoint.hostname should be used, but unsure about the other possible implications of this change.
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: