https://www.baeldung.com/aws-s3-multipart-upload
Код: Выделить всё
// Prepare the parts to be uploaded
List completedParts = new ArrayList();
int partNumber = 1;
ByteBuffer buffer = ByteBuffer.allocate(5 * 1024 * 1024); // Set your preferred part size (5 MB in this example)
// Read the file and upload each part
try (RandomAccessFile file = new RandomAccessFile(filePath, "r")) {
long fileSize = file.length();
long position = 0;
while (position < fileSize) {
file.seek(position);
int bytesRead = file.getChannel().read(buffer);
buffer.flip();
UploadPartRequest uploadPartRequest = UploadPartRequest.builder()
.bucket(existingBucketName)
.key(keyName)
.uploadId(uploadId)
.partNumber(partNumber)
.contentLength((long) bytesRead)
.build();
UploadPartResponse response = s3.uploadPart(uploadPartRequest, RequestBody.fromByteBuffer(buffer));
Как будет настроен этот клиент? Здесь говорится, что для этой цели RestTemplate можно использовать для запросов составных файлов:
Запросы составных файлов разбивают большой файл на более мелкие фрагменты и используют
граничные маркеры для обозначения начала и конца блока.
Я предполагаю, что смогу использовать такой составной Spring API, если клиент настроен правильно?https://spring.io/guides/gs/uploading-files
Подробнее здесь: https://stackoverflow.com/questions/788 ... large-file
Мобильная версия