Skip to content

Commit

Permalink
Error uploading an empty file #11
Browse files Browse the repository at this point in the history
  • Loading branch information
glebshalyganov committed Aug 13, 2021
1 parent 46d152c commit 07fb639
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ public void saveFile(FileDescriptor fileDescr, byte[] data) throws FileStorageEx
S3Client s3Client = s3ClientReference.get();
int chunkSize = amazonS3Config.getChunkSize() * 1024;

if (data.length == 0) {
s3Client.putObject(PutObjectRequest.builder()
.bucket(getBucket())
.key(resolveFileName(fileDescr))
.build(), RequestBody.fromBytes(data));
return;
}

CreateMultipartUploadRequest createMultipartUploadRequest = CreateMultipartUploadRequest.builder()
.bucket(getBucket()).key(resolveFileName(fileDescr))
.build();
Expand Down

0 comments on commit 07fb639

Please sign in to comment.