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)
)
}
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()
}
}
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