Unable to download file from Azure blob java

Zelin Wang (US) 20 Reputation points
2024-10-16T22:11:48.0966667+00:00

Hi community members,

I am trying to download file that contains asian characters in blob path but has StorageException. the api i am using is downloadFile("temp/document/9795ccd9-4a41-4bf1-80d5-43774cac0c89/*我愛中國.*pdf"). The api itself path format has no issues while downloading normal english file name but it only has issues while downloading file with foreign language names. Could you help me to resolve this? thank you so much!

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
{count} votes

Accepted answer
  1. Vinod Kumar Reddy Chilupuri 4,185 Reputation points Microsoft External Staff Moderator
    2024-10-21T03:39:19.17+00:00

    Hi Zelin Wang (US),

    The "TranslateException" you are seeing due to the issue with the Azure Storage SDK or due to the connection to Azure Blob Storage.

    Here are few steps to follow.

    • Check whether the blob blobPath is URL-encoded properly. Non-ASCII characters need to be properly encoded to ensure they are transmitted over HTTP without any errors.
    • The path you are using in the downloadToFile method should not contain double slashes (//). This will raise the issues when the file is being created. Use only single slash (/).
    • Check the BlobPath variable is correctly is pointing to the blob you want to download. Verify it through a console output can help that it is encoded properly and matches the actual blob path within the container.
    • Check that the container and the blob exists in Azure Blob Storage. You can use the Azure Portal or Azure Storage Explorer to check if the blob exists and check you have the correct permissions to access it.
    • Check the connection details that your connection string, account name, key are valid. You can create a CloudStorageAccount and a CloudBlobClient to check if you're able to connect properly. If there is any issue with the connection, it will cause exceptions during blob access.

    By ensuring that the blob path is properly URL-encoded and correcting the file path format, you should be able to resolve the "TranslateException" and successfully download the file with Asian characters in its name.

     

    • Upload: No need to encode the file name, as Azure handles non-ASCII characters without issues.
    • Download/Access: Ensure the blob path is URL-encoded (especially for non-ASCII characters) to avoid errors during access.

    Please let us know if you have any further queries. I’m happy to assist you further. 


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.