question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure storage overwrite option not available

See original GitHub issue

Expected 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:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zhoufenqincommented, Sep 16, 2020

Hi @revoorunischal, we have release the library. The Storage Spring Boot Starter version:

<dependency>
      <groupId>com.microsoft.azure</groupId>
      <artifactId>spring-starter-azure-storage</artifactId>
      <version>1.2.8</version>
</dependency>

The Spring Boot Storage version:

<dependency>
      <groupId>com.microsoft.azure</groupId>
      <artifactId>spring-cloud-azure-storage</artifactId>
      <version>1.2.8</version> 
</dependency>

You can choose what you need.

Closing the issue

0reactions
saraglunacommented, Aug 7, 2020

@revoorunischal next release will be in several weeks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Don't Overwrite Azure Blob Storage - Stack Overflow
By design, Azure Blob Storage will overwrite the contents of a blob if you're trying to upload new content with same blob name....
Read more >
Failure to Overwrite Files in Blob Storage
Overview. There is currently an issue on SFTP Gateway version 2.000.00 - 2.001.06 when attempting to overwrite files in Blob Storage.
Read more >
Azure Logic App - Overwrite Blob - Microsoft Q&A
When using "Create Blob" to write a blob from Logic App to Blob storage v2, I get the following error when there's an...
Read more >
BlobClient.Upload Method (Azure.Storage.Blobs)
Setting overwrite to true allows updating the content of an existing block blob. Updating an existing block blob overwrites any existing metadata on...
Read more >
Overview of immutable storage for blob data - Azure
Storage account deletion fails if there is at least one container that contains a blob version with a locked time-based retention policy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found