Search code examples
javaspringazureazure-blob-storagefrench

Dowload files from Azure Blob Storage with French filename


I am using Java SDK for connection to Azure Blob Storage:

@Bean
@SneakyThrows
public CloudBlobContainer sourceContainer(CloudStorageAccount cloudStorageAccount) {
    return cloudStorageAccount
            .createCloudBlobClient()
            .getContainerReference(sourceContainerName);
}

During the download process, I am taking listBobs and the necessary CloudBlockBlob.

It exists in the list of blobs. Then I try to download it:

blob.downloadToFile(path);
blob.delete();

And it fails with error:

Method threw 'com.microsoft.azure.storage.StorageException' exception.
The specified blob does not exist.

The interesting fact is that when I rename blob to remove the french accent letters it works as expected. But I can't resolve it from server side. I can't copy to blob with a filename without french accent letters since every oberation on CloudBlockBlob fails with 404 HTTP code


Solution

  • I test with azure-storage 5.0.0 and it could download the file with associé.txt name. Maybe you could try with my code or provide more information to let me have a test.

        final String storageConnectionString ="connectionstring";
    
        CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
    
        CloudBlobClient serviceClient = account.createCloudBlobClient();
    
        CloudBlobContainer container = serviceClient.getContainerReference("test");
        container.createIfNotExists();
    
        File file = new File("E:\\Test");
        for(ListBlobItem item : container.listBlobs()){
            CloudBlockBlob cloudBlob = (CloudBlockBlob) item;
            File f = new File(file.getAbsolutePath() + "\\" +cloudBlob.getName() );
            cloudBlob.downloadToFile(f.toString());
            System.out.println(cloudBlob.getName()+" success download");
        }
    

    enter image description here