-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
s3 head object, erroneously modified object name #2982
Comments
Hello @luoyanpeng-bytedancer, thanks for reaching out. For doing head object operations on S3 key names that contains characters such as "/" and "+", you would need to encode those characters as they are identified as special characters for S3 (https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html). So for the request, it would need to have the encoded version of the characters. If you have any questions, please do let me know. Thanks. |
Why boto3 can not encode "/", and why only "/+ bucket name" has this problem |
The way I have replicated on my side is that:
My snippet of code for Head Object:
From the above, If you have any other questions, please let me know. Thanks. |
There are some misunderstandings here, try objectKey = "/bucket-name/sample.png" and set the endpoint |
I tried with "/bucket-name/sample.png" and I did not get a 404 error. Can you provide (and code) : |
This issue has not received a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled. |
Sorry, an error message was given, the object name should be "bucket-name/sample.png". `region := "ap-southeast-1"
I tried it, if I don't use "AWS. EndpointResolverFunc" is fine, but since I will use storage services from other vendors, I need to use this |
Please read through https://docs.aws.amazon.com/sdk-for-go/v2/developer-guide/configure-endpoints.html.
Aside, this SDK is designed to work with official AWS services, I can't guarantee you it will function against anything else. Since @adev-code has verified that the behavior you're seeing isn't occuring with the (default) v2 endpoint resolution, I'm going to close this. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
s3 head object:If the object name starts with"/+ bucket name", the SDK will remove the bucket name from the object name in the path of the URL, causing the request to return 404.
code :
s3@v1.73.2 internal/customizations/update_endpoint.go
func moveBucketNameToHost(u *url.URL, bucket string) { u.Host = bucket + "." + u.Host removeBucketFromPath(u, bucket) }
Regression Issue
Expected Behavior
Object names should not be modified
Current Behavior
If the object name starts with"/+ bucket name", the SDK will remove the bucket name from the object name in the path of the URL
Reproduction Steps
Head An object prefixed with "/+ bucket name"
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
Compiler and Version used
go version go1.21.7 darwin/amd64
Operating System and version
macOS 14.0 (23A344)
The text was updated successfully, but these errors were encountered: