Azure storage overwrite option not available
See original GitHub issueExpected Behavior
When data is copied to particular file on cloud. if the file already exists. I want to overwrite it.
Current Behavior
I get the following error if the file already exists
java.lang.IllegalArgumentException: Blob already exists. Specify overwrite to true to force update the blob. at com.azure.storage.blob.specialized.BlockBlobClient.getBlobOutputStream(BlockBlobClient.java:100) ~[azure-storage-blob-12.5.0.jar:na] at com.azure.storage.blob.specialized.BlockBlobClient.getBlobOutputStream(BlockBlobClient.java:86) ~[azure-storage-blob-12.5.0.jar:na] at com.microsoft.azure.spring.cloud.storage.BlobStorageResource.getOutputStream(BlobStorageResource.java:67) ~[spring-cloud-azure-storage-1.2.7.jar:1.2.7] at com.finacle.cloudStorageReadWrite.Controller.uploadData(Controller.java:52) ~[classes/:na]
Possible Solution
Give an option to set this flag from resources
Steps to Reproduce (for bugs)
- step-1 - create a file in azure-blob
- step-2 - try to replace the same file.
Snapshot Code for Reproduce
@GetMapping("/upload")
public String uploadData(@RequestParam String url,@RequestParam String data){
WritableResource resource = (WritableResource) resourceLoader.getResource(url);
try (OutputStream outputStream = resource.getOutputStream()) {
outputStream.write(data.getBytes(Charset.forName("UTF-8")));
return "Success";
} catch (IOException e) {
e.printStackTrace();
}
return "Fail";
}
Branch
1.2.7
Your Environment
- Version used: 1.2.7
- Operating System and version (desktop or mobile): Mac ,
- SDK version: 1.2.7
- spring boot : 2.2.9.RELEASE and 2.3.1.RELEASE
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Hi @revoorunischal, we have release the library. The Storage Spring Boot Starter version:
The Spring Boot Storage version:
You can choose what you need.
Closing the issue
@revoorunischal next release will be in several weeks.