Skip to content

BlobContainerClient.StartDownloadToDirectoryAsync url-encodes subdirectories containing spaces. #315

@lardogbeck

Description

@lardogbeck

Which service(blob, file) does this issue concern?

Blob

Which version of the SDK was used?

<PackageVersion Include="Azure.Storage.Blobs" Version="12.20.0-beta.1" />
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.12.1" />
<PackageVersion Include="Azure.Storage.Queues" Version="12.12.0" />
<PackageVersion Include="Azure.Storage.DataMovement" Version="12.0.0-beta.4" />
<PackageVersion Include="Azure.Storage.DataMovement.Blobs" Version="12.0.0-beta.4" />

On which platform were you using? (.Net Framework version or .Net Core version, and OS version)

.NET 6

How can the problem be reproduced? It'd be better if the code caused the problem can be shared.

Create a blob name in path format containing spaces, e.g. 20348.1.x64.fe_release.210507-1500_server_serverstandard_en-us_vl/Virtual Hard Disks/20348.1.amd64fre.fe_release.210507-1500_server_serverstandard_en-us_vl.vhd

Then execute the following to download it from the container with prefix 20348.1.x64.fe_release.210507-1500_server_serverstandard_en-us_vl

             BlobContainerClientTransferOptions blobContainerClientTransferOptions = new BlobContainerClientTransferOptions()
            {
                BlobContainerOptions = new BlobStorageResourceContainerOptions()
                {
                    BlobDirectoryPrefix = blobPrefix,
                    BlobType = BlobType.Block,
                },
                TransferOptions = new DataTransferOptions()
                {
                    CreationPreference = overwrite ? StorageResourceCreationPreference.OverwriteIfExists : StorageResourceCreationPreference.FailIfExists,
                },
            };

            DataTransfer dataTransfer = await blobContainerClient.StartDownloadToDirectoryAsync(destPath, blobContainerClientTransferOptions).ConfigureAwait(false);

            await dataTransfer.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);

What problem was encountered?

Expect the blob name segment "Virtual Hard Disks" to appear as subdir "Virtual Hard Disks". Instead it appears URL encoded as "Virtual%20Hard%20Disks".

Have you found a mitigation/solution?

Nothing other than making a rename pass after the download. Can't remove the spaces in this case because Hyper-V expects these directory names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions