我已经使用 Azure Blob 存储 REST API 几天了。
我可以连接到资源、列出容器、为任何给定容器生成 SAS 令牌,最近还可以列出容器内的 blob(请参阅此处:Azure Blob 存储(REST API):无法使用curl 列出容器中的 blob) SAS 令牌)没有任何问题。
但是,我现在在尝试使用为容器生成的 SAS 令牌下载容器内的 blob 时遇到问题。
使用生成的 SAS 令牌,我尝试了以下curl 命令来下载 blob:
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01/3c6a1ba9-2168-4171-8311-813e3762108b.txt&sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
地点:
blobServiceUri: https://dat3473spa01cfeMtest.blob.core.windows.net
container name: 90480397-91234697-218-test-dir01
blob name: 3c6a1ba9-2168-4171-8311-813e3762108b.txt
SAS token for container: ?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl
当我运行curl命令时,出现错误:
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>ResourceNotFound</Code>
<Message>The specified resource does not exist.
RequestId:8feff5f9-001e-006d-5b18-260db0000000
Time:2024-10-24T13:28:25.9692381Z</Message>
</Error>
运行以下任一curl命令(将初始curl命令中的
.txt&
替换为.txt&?
或.txt?
):
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01/3c6a1ba9-2168-4171-8311-813e3762108b.txt&?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01/3c6a1ba9-2168-4171-8311-813e3762108b.txt?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
给出错误:
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>BlobNotFound</Code>
<Message>The specified blob does not exist.
RequestId:4978f267-601e-0043-3419-26bc10000000
Time:2024-10-24T13:32:22.1650304Z</Message>
</Error>
当我使用命令列出容器中的 blob 时
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01?restype=container&comp=list&sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
我得到:
90480397-91234697-218-test-dir01/3c6a1ba9-2168-4171-8311-813e3762108b.txt
所以该 blob 已列出,但我无法下载它!
SAS 的分隔字符是“?”你需要将其更改为如下所示:
https://yourbloburl?yoursastoken
这是文档的链接 https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview