Skip to content

Commit

Permalink
Handle uploading empty file (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Feb 8, 2022
1 parent 7443dd3 commit 89b407b
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;

public class UploadToFileService extends UploadService {

private static final String EMPTY_STRING_MD5 = "68b329da9893e34099c7d8ad5cb9c940";

public UploadToFileService(UploadServiceData serviceData) {
super(serviceData);
}
Expand Down Expand Up @@ -159,6 +163,20 @@ private UploadResult uploadCloudFile(ShareFileClient fileClient, UploadObject up
long bytes = Files.size(file.toPath());
fileClient.create(bytes);

// https://github.com/Azure/azure-sdk-for-java/issues/26867
if (bytes == 0L) {
long endTime = System.currentTimeMillis();
return new UploadResult(HttpStatus.SC_CREATED, null,
EMPTY_STRING_MD5,
file.getName(),
uploadObject.getUrl(),
bytes,
uploadObject.getStorageType(),
startTime,
endTime
);
}


ShareFileUploadOptions fileUploadOptions = new ShareFileUploadOptions(bis);
Response<ShareFileUploadInfo> response = fileClient
Expand Down

0 comments on commit 89b407b

Please sign in to comment.