-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Caching image with token (Amazon S3 bucket image) #602
Comments
i think you can use |
I did but it doesn't work. Is there any example for it? |
not that i could find, unfortunately. what does your errors say? |
@junkdeck There is no error. Just it doesn't cache it. :/ |
how did you fetch the image using the header key? been trying at it without any luck for hours |
Any updates here? |
I have the same problem. Signed urls aren't cached. Is there any update on this? |
Take a look here: aws-amplify/amplify-js#5296 (comment) You can supply the |
Hi Andrei, I checked your Our client side application just has a url like this: Is it possible to generate signed headers using this url? |
@boraikizoglu How are you generating the URL? As you can see it has an expiration date tied to it. Storing signed URLs in a database is not recommended. The link I added shows a solution that takes advantage of Amazon Cognito based temporary credentials -> the signature is safe to be generated in the React Native app because the accesskey/secretkey/sessiontoken are tied to the currently logged in Cognito user. So, they're temporary and tied to the current user. AWS Amplify makes this easy. If you cannot generate signatures client side one possible workaround is to set up an API function on your server which returns the set of signed headers based on server side AWS credentials, and then use those in your app to do the request. |
@andreialecu, we don't store any signed URL in the database. They are generated in the server side each time user requests an image. I finally managed to solve this issue. Instead of sending pre-signed urls, like @andreialecu mentioned, send
|
Hi @boraikizoglu, is it working properly? |
@randalb1991 it worked fine for me. |
Hi, I tried the suggested solutions but nothing worked to me. Does anyone have another solution that worked? |
Using the Authorization headers works with S3 signed URLs but I am using CloudFront which does not support inclusion of the signature info inside of Authorization headers. If you're using S3 directly (not through CloudFront) see here: |
I am still dealing with this issue. I am using |
How to do this with |
@roots-ai You can use whatever SDK you want to generate the URL signature on your server. You can make caching work once delivering the signed URL to your client by pulling the signature out of the query/URL parameters and including it in the Authorization header like this: If you're using CloudFront signed URLs (instead of S3 directly) you can include the signature in a Cookie header instead: |
This repo caters for the above issue but still needs work: |
I am trying to cache an image from Amazon S3 bucket, but this url has lots of variables. So I want to cache the image for only first part of url. Is it possible?
for an example:
https://mybucket-dev.s3.ap-northeast-1.amazonaws.com/public/user/805327c1-8a64-4f94-a044-a2f158b2d677/feed/feed_20191117011738039.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA2DSNUBOKIKRUQDRV%2F20191116%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20191116T174021Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEFIa
the first part of url always same:
https://mybucket-dev.s3.ap-northeast-1.amazonaws.com/public/user/805327c1-8a64-4f94-a044-a2f158b2d677/feed/feed_20191117011738039.jpg
Can I use this part as a cache key?
Thank you.
The text was updated successfully, but these errors were encountered: