question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No option to get the URL of item in S3 bucket using key.

See original GitHub issue

I have files(pictures) in my S3 bucket and I am displaying them on screen. I don’t want to use the Amplify.Storage.downloadFile(...) as it takes a lot of time to download and then render. I want to use a picture loading library like glide and to do that I need to get the URL of the picture (probably by using the key). Currently there is no such option in android.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
raphkimcommented, Feb 6, 2020

But I think there should be a simpler way to do it in near future.

There will be! Please continue to follow our project for the upcoming changes and thank you for using Amplify 😃

2reactions
raphkimcommented, Jan 28, 2020

Amplify Storage internally constructs a “service key”, which is a combination of StorageDownloadFileOptions, AWSMobileClient#getIdentityId(), and S3 key. This service key can be constructed using S3RequestUtils and be passed directly as a key along with the bucket name to generatePresignedUrl(). I imagine the sample code for temporary workaround would look like the following:

StorageDownloadFileOptions options = StorageDownloadFileOptions.defaultInstance(); // This is your download file options
String identityId = AWSMobileClient.getInstance().getIdentityId();
String serviceKey = S3RequestUtils.getServiceKey(
    options.getAccessLevel(),
    identityId,
    key,
    options.getTargetIdentityId()
);

AmazonS3Client s3 = Amplify.Storage.getEscapeHatch();
URL url = s3.generatePresignedUrl(
    bucketName, 
    serviceKey, 
    null
);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods for accessing a bucket - AWS Documentation
You can access your bucket using the Amazon S3 console. Using the console UI, you can perform almost all bucket operations without having...
Read more >
How to Allow Public Access to an Amazon S3 Bucket & Find ...
1. From the bucket list, click on the bucket name again. Select the Permissions tab again, but this time go to the Bucket...
Read more >
Amazon S3 upload file and get URL - Stack Overflow
No you cannot get the URL in single action but two :) First of all, you may have to make the file public...
Read more >
How can I grant public read access to some objects ... - YouTube
How can I grant public read access to some objects in my Amazon S3 bucket ?
Read more >
Why can't I access a specific folder or file in my Amazon S3 ...
Ownership of the prefix or object · Restrictions in the bucket policy · Restrictions in your AWS Identity and Access Management (IAM) user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found