【问题标题】:How to correctly grab blob names with whitespaces in azure from az cli如何从 az cli 正确获取带有空格的 blob 名称
【发布时间】:2020-01-22 23:54:00
【问题描述】:

我有一个用户在他们的文件名中添加了很多空格,这导致下载脚本出错。

要获取 blob 的名称,我使用这个:

BLOBS=$(az storage blob list --container-name $c \
--account-name $AZURE_STORAGE_ACCOUNT  --account-key $AZURE_STORAGE_KEY \
--query "[].{name:name}" --output tsv) 

对于像 blob with space.pdf 这样的 blob 正在发生什么,它被存储为 [blob\twith\tspace.pdf] 其中 \t 是选项卡。当我反复尝试下载时,显然我无法获取该文件。

我怎样才能正确地做到这一点?

【问题讨论】:

  • 您要下载容器中名称包含空格的 blob?
  • @IvanYang 没错。
  • 抱歉,一两天忙于非编程生活。

标签: azure azure-blob-storage


【解决方案1】:

你可以使用这个命令az storage blob download-batch。

我在 azure 门户中对其进行了测试,包括名称中包含空格的所有 blob 都已下载。

命令:

c=container_name
AZURE_STORAGE_ACCOUNT=xx
AZURE_STORAGE_KEY=xx

//download the blobs to clouddrive
cd clouddrive

az storage blob download-batch -d . -s $c --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_KEY

测试结果:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-21
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    • 2022-11-09
    • 1970-01-01
    • 2019-04-02
    相关资源
    最近更新 更多