gpt4 book ai didi

rest - 无法使用 REST API 和curl 从 Azure 文件存储检索文件列表

转载 作者:行者123 更新时间:2023-12-02 07:26:40 26 4
gpt4 key购买 nike

我正在尝试使用 REST API 和curl 检索存储在Azure 文件存储帐户中的文件列表,我使用共享 key 根据文档正确计算了 header ,但curl 请求既不返回文件列表也不返回任何错误消息。

这是我的请求和响应:

curl -v -H "Authorization: SharedKey myaccount:bAJKeY0xyOZLSJOLDoHfXXOqfA4kOGo1DVFP3BejhY8=" -H "x-ms-date:Mon, 13 Aug 2018 15:22:31 GMT" -H "x-ms-version:2017-07-29" --url https://myaccount.file.core.windows.net/myshare/mydir?restype=directory&comp=list

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 52.239.140.8...

* Connected to myaccount.file.core.windows.net (52.239.140.8) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 597 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_256_GCM_SHA384
* server certificate verification OK
* server certificate status verification SKIPPED
* common name: *.file.core.windows.net (matched)
* server certificate expiration date OK
* server certificate activation date OK
* certificate public key: RSA
* certificate version: #3
* subject: CN=*.file.core.windows.net
* start date: Thu, 09 Nov 2017 05:42:03 GMT
* expire date: Sat, 09 Nov 2019 05:42:03 GMT
* issuer: C=US,ST=Washington,L=Redmond,O=Microsoft Corporation,OU=Microsoft IT,CN=Microsoft IT TLS CA 5
* compression: NULL
* ALPN, server did not agree to a protocol

GET /myshare/mydir?restype=directory HTTP/1.1

Host: myaccount.file.core.windows.net

User-Agent: curl/7.47.0

Accept: */*

Authorization: SharedKey
myaccount:bAJKeY0xyOZLSJOLDoHfXXOqfA4kOGo1DVFP3BejhY8=
x-ms-date:Mon, 13 Aug 2018 15:22:31 GMT
x-ms-version:2017-07-29

HTTP/1.1 200 OK

Transfer-Encoding: chunked

Last-Modified: Fri, 27 Apr 2018 16:11:14 GMT

ETag: "0x8D5AC597FF96B3D"

Server: Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0

x-ms-request-id: 75d6d7c8-f01a-0011-5b19-33104d000000

x-ms-version: 2017-07-29

x-ms-server-encrypted: true

Date: Mon, 13 Aug 2018 15:22:29 GMT

{ [5 bytes data]
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Connection #0 to host myaccount.file.core.windows.net left intact

没有返回带有文件列表的 XML。我尝试检索我的帐户下的共享列表,它可以工作,并且可以下载单个文件,但我无法接收目录下的文件列表。

最佳答案

两点:

  1. 在curl命令中查看url

    --url https://myaccount.file.core.windows.net/myshare/mydir?restype=directory&comp=list

    您忘记将网址放入 "" 中,因此参数 &comp=list 被删除,因为 & 是保留符号。输出 GET/myshare/mydir?restype=directory HTTP/1.1 也证明了这一点。

  2. 一般来说,如果 url 缺少 comp 参数,我们应该收到错误消息 AuthenticationFailed,因为 comp 用于生成 SharedKey。但是,您可以通过 SharedKey 获得 HTTP/1.1 200 OK

    根据你得到的响应头,我猜你在构造SharedKey时也错过了comp,所以SharedKey和url能够得到directory properties正确。

关于rest - 无法使用 REST API 和curl 从 Azure 文件存储检索文件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51825902/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com