LiveUI / S3

S3 Client written in Swift
MIT License
93 stars 60 forks source link

Presigned URL returns 403 #11

Closed staffler-xyz closed 5 years ago

staffler-xyz commented 6 years ago

Hi!

First of all, thanks for the library - upload is already working :-)

However, I have some problems when generating a presigned url, which always leads to 403 errors. Is this the correct way to do it?

let s3Client = try request.make(S3Client.self)

let url = try s3Client.url(fileInfo: pathToFile, on: request)

let s3Signer = try request.make(S3Signer.self)

let presignedUrl = try s3Signer.presignedURL(for: .GET, url: url, expiration: Expiration.threeHours)

I get back this url: https://s3.<region>.amazonaws.com/<bucket>/path/to/file.mp3?x-amz-algorithm=AWS4-HMAC-SHA256&x-amz-credential=<credentials>&x-amz-date=<date>&x-amz-expires=<date>&x-amz-signedheaders=host&x-amz-signature=<credentials>

When the file is public it works, but for private files I get the 403 error.

rafiki270 commented 6 years ago

@overovermind sorry, holidays ... will check and get back to you hopefully in a few days ... either way, this part is in signer and is actually pretty simple when you look ...

staffler-xyz commented 6 years ago

yeah it should work, but it seems there is a problem with the signing somewhere. I tried different urls and manual uploads too, but with no success. Do you think it could be related to the bucket region? Currently I am using euCentral1.

staffler-xyz commented 5 years ago

Any updates on this? Do you have an example how you sign urls?

rafiki270 commented 5 years ago

@overovermind unfortunately not yet :(

Joebayld commented 5 years ago

Having the same issue here.. Trying to figure this out..

Joebayld commented 5 years ago

I think I fixed this. https://github.com/LiveUI/S3/pull/28

staffler-xyz commented 5 years ago

Wow, great! Many thanks @Joebayld 👍👍