Giter VIP home page Giter VIP logo

s3uploadservice's Introduction

S3UploadService [android]

Implementation of an IntentService that receives a File and information about an S3 bucket. The service handles the upload of said file to the bucket.

Usage

Build an instance of S3BucketData and make a call to S3UploadService.upload():

        S3Credentials s3Credentials = new S3Credentials(accessKey, secretKey, sessionToken);
        S3BucketData s3BucketData = new S3BucketData.Builder()
                .setCredentials(s3Credentials)
                .setBucket(bucket)
                .setKey(key)
                .setRegion(region)
                .build();
                
        S3UploadService.upload(context, s3BucketData, file, null);

where key is:

        key = pathToFile + "/" + fileName;

key could be just the fileName

keep in mind that the final URL will have the following format:

        finalUrl = "https://" + bucket + ".s3.amazonaws.com/" + key;

Callback

S3Callback is an optional parameter in the upload() method. If not null, it should contain a String indicating what action will be broadcasted after upload completion. Optionally, you can add a Serializable to receive extra data

        s3Callback = new S3Callback("com.example.android.S3_UPLOAD_COMPLETED", "Awesome message");

If s3Callback is provided to the upload() method, after the upload is completed, the following lines will be executed inside S3UploadService:

        Intent intent = new Intent(s3Callback.getActionCallback());
        intent.putExtra(EXTRA_SERIALIZABLE, s3Callback.getExtra());
        sendBroadcast(intent);

So if we have a BroadcastReceiver capturing the specified action, it will receive the broadcast message along with the string "Awesome message"

Download

Add the JitPack repository to your root build.gradle:

	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

Add the Gradle dependency:

	dependencies {
		compile 'com.github.OneCodeLabs:S3UploadService:1.0.0@aar'
	}

Declare S3UploadService in your manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="$package_name">

    <application
        ...>
        
        ...
        
        <service
            android:name="com.onecode.s3.service.S3UploadService"
            android:exported="false" />
    </application>

</manifest>

s3uploadservice's People

Watchers

James Cloos avatar JSBerrocoso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.