Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

Is there a way to download a file from an S3 bucket using Android's DownloadManager?

I can currently download an apk file from Dropbox doing this:

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

request.addRequestHeader("Content-Type", "application/vnd.android.package-archive");

request.setMimeType("application/vnd.android.package-archive");

final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);

final long id = manager.enqueue(request);

Now what I want to do is replace "url" with my Amazon URL. When I do this, the download just stays at 0% and just gets stuck there.

Is there any way to do this?

By the way, the Amazon URL I pass in contains the AWSAccessKeyId, Expires, and Signature parameters. The URL looks like this:

https://bucket-name.s3-us-west-2.amazonaws.com/uploads/app/apk/22/app.apk?AWSAccessKeyId=""&Expires=""&Signature=""

1 Answer

0 votes
by (44.4k points)

This will work:

request.addRequestHeader("Content-Type", "application/vnd.android.package-archive");

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...