Skip to content
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

File not found if S3 key contains special characters #279

Closed
khacminh opened this issue Apr 1, 2021 · 2 comments
Closed

File not found if S3 key contains special characters #279

khacminh opened this issue Apr 1, 2021 · 2 comments
Milestone

Comments

@khacminh
Copy link
Contributor

khacminh commented Apr 1, 2021

Issue:

S3 key may contain special characters as mention in this document. In this case, downloading S3 object throws 404 error.

Solution:

The S3 key need to be URL encoded before download.

@khacminh khacminh changed the title Find not found if S3 key contains special characters File not found if S3 key contains special characters Apr 1, 2021
@khacminh khacminh mentioned this issue Apr 1, 2021
@ilkinulas
Copy link
Member

Hi @khacminh, thank you for reporting this.

Could you please give an example (and valid) s3 prefix where download s3 object request throws 404 error?

@khacminh
Copy link
Contributor Author

khacminh commented Apr 5, 2021

Hi @ilkinulas

The source bucket has the following objects:

test-dir/object-2021-04-04+1.txt
test-dir/object-2021-04-04:2.txt

Then I would like to copy them to the new bucket with the following command

s5cmd cp srcBucket/* dstBucket/

According to AWS document, the following character must be handled by URL encoding or referenced as HEX:

  • Ampersand ("&")
  • Dollar ("$")
  • 'At' symbol ("@")
  • Equals ("=")
  • Semicolon (";")
  • Colon (":")
  • Plus ("+")
  • Space
  • Comma (",")
  • Question mark ("?")

Encoding the url component fix this issue. However, it breaks another test cases using wildcard.

ilkinulas pushed a commit that referenced this issue Apr 22, 2021
* modify URL.remoteURL(): add encode URI Component

* add unit test for URL.remoteURL()

* replace go-funk

* move url.QueryEscape to s3.go

* add test - but with error

* modify test

* fix test

* - move s3.go/escapeKey to url.go/GetCopySource
- switch to https://github.com/johannesboyne/gofakes3
- add assertion

* replace gofakes3 and rename method GetCopySource

* revert go.mod

Co-authored-by: Minh Ho <minhho@itrvn.com>
@ilkinulas ilkinulas added this to the v1.3.0 milestone Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants