Send multiple files with S3TransferManager without physical directory

Viewed 36

Does anyone know how can I send multiple files (as a file list MutableList<File> that I populate within a loop) using the S3TransferManager method uploadDirectory without needing to create the files physically on my disc? It does't need to use uploadDirectory method, but I don't want to save them on disc before send them to S3, I have them on memory and I'd like o keep it that way. Here is my code block so far:

val s3Request = PutObjectRequest.builder()
            .bucket(bucket)
            .key(s3Key)
            .contentType("application/json; charset=UTF-8")
            .build()
val tm = S3TransferManager.create()
// sending only one file
val upload = tm.uploadFile { b -> b.source(createFileFromBytes(file)).putObjectRequest(s3Request) }
upload.completionFuture().join()

...
// is there something like (supose my fileMutableList already have all the files I want to send)
val uploads = tm.uploadFiles { b -> b.source(fileMutableList).putObjectsRequest(s3Request) }
uploads.completionFuture().join()
...

I'm using the software.amazon.awssdk:s3-transfer-manager:2.17.123-PREVIEW lib for Java on my Kotlin project, which you can find out more about it here.

Any thoughts are very appreciated.

0 Answers
Related