I need to upload a bitmap to Amazon S3. I have never used S3, and the docs are proving less than helpful as I can't see anything to cover this specific requirement. Unfortunately I'm struggling to find time on this project to spend a whole day learning how it all hangs together so hoping one of you kind people can give me some pointers.
Can you point to me to a source of reference that explains how to push a file to S3, and get a URL reference in return?
More specifically: - Where do the credentials go when using the S3 Android SDK? - Do I need to create a bucket before uploading a file, or can they exist outside buckets? - Which SDK method do I use to push a bitmap up to S3? - Am I right in thinking I need the CORE and S3 libs to do what I need, and no others?
you can upload image and download image in s3 amazon. you make a simple class use this WebserviceAmazon
call this webservice any where in project
You can use a library called S3UploadService. First you would need to convert your Bitmap to a File. To do so take a look at this post:
Convert Bitmap to File
S3UploadService is a library that handles uploads to Amazon S3. It provides a service called S3UploadService with a static method where you provide a Context (so the static method can start the service), a File, a boolean indicating if said file should be deleted after upload completion and optionally you can set a callback (Not like an ordinary callback though. The way this works is explained in the README file).
It's an IntentService so the upload will run even if the user kills the app while uploading (because its lifecycle is not attached to the app's lifecycle).
To use this library you just have to declare the service in your manifest:
Then you build an S3BucketData instance and make a call to S3UploadService.upload():
To add this library you need to add the JitPack repo to your root build.gradle:
and then add the dependency:
Here is a link to the repo: https://github.com/OneCodeLabs/S3UploadService
This answer is a bit late, but I hope it helps someone
you can use the below mentioned class to Upload data to amazon s3 buckets.
}
use the below method to access the above calss :
We can directly use "Amazone s3" bucket for storing any type of file on server, and we did not need to send any of file to Api server it will reduce the request time.
Gradle File :-
Manifest File :-
FileUploader Function in any Class :-
Take a look at the Amazon S3 API documentation to get a feel for what can and can't be done with Amazon S3. Note that there are two APIs, a simpler REST API and a more-involved SOAP API.
You can write your own code to make HTTP requests to interact with the REST API, or use a SOAP library to consume the SOAP API. All of the Amazon services have these standard API endpoints (REST, SOAP) and in theory you can write a client in any programming language!
Fortunately for Android developers, Amazon have released a (Beta) SDK that does all of this work for you. There's a Getting Started guide and Javadocs too. With this SDK you should be able to integrate S3 with your application in a matter of hours.
The Getting Started guide comes with a full sample and shows how to supply the required credentials.
Conceptually, Amazon S3 stores data in Buckets where a bucket contains Objects. Generally you'll use one bucket per application, and add as many objects as you like. S3 doesn't support or have any concept of folders, but you can put slashes (/) in your object names.