Skip to content

Fauzdar1/MultiUploaderS3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MultiUploaderS3

This is to upload/download multiple files in/from Amazon S3 concurrently.

Initialize S3Client in MultiUploaderS3 or MultiDownloaderS3 as

fun s3ClientInitialization(context: Context): AmazonS3 {
    val cognitoCachingCredentialsProvider = CognitoCachingCredentialsProvider(
        context,
        your key,
        region
    )
    return AmazonS3Client(
        cognitoCachingCredentialsProvider,
        Region.getRegion(Regions.YOUR_REGION)
    )
}

Upload multiple files from your Activity as

val map: Map<File, String> = yourArrayList.map {it to Your_Key_For_Each_File}.toMap()
MultiUploaderS3().uploadMultiple(map, this)
    .subscribeOn(Schedulers.io())
    .observeOn(Schedulers.io())
    .subscribe {
        runOnUiThread {
            Toast(this@AddActivity, "Uploading completed", Toast.LENGTH_LONG).show()
        }
     }

Download multiple files from your Activity as

val map: Map<File, String> = yourKeysArrayList.map {Your_FILE_For_Each_KEY to it}.toMap()
MultiDownloaderS3().downloadMultiple(map, this)
    .subscribeOn(Schedulers.io())
    .observeOn(Schedulers.io())
    .subscribe {
        runOnUiThread {
            Toast(this@AddActivity, "Downloading completed", Toast.LENGTH_LONG).show()
        }
     }

I've also provided this as an answer on StackOverflow - Amazon s3 upload multiple files android

Here's the original answer provided by a member of AWS Amplify Organization from which I've implemented this - Upload Multiple files using TransferUtility

About

This is to upload/download multiple files in/from Amazon S3 concurrently.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages