curl (bash スクリプト内) を使用して、 PUT Blobを使用してファイルをAzure Blob Storage にアップロードしています。ファイルを保存する場所へのパスを URL エンコードすると"https://${endpoint}/${container_name}/a/b/c/te%20st.txt"
(元のファイル名は「te st.txt」)、正規のリソース文字列に同じパスを入れると、"/${account_name}/${container_name}/a/b/c/te%20st.txt"
「AuthenticationFailed」エラーが発生します。「Authorization: SharedKey ${account_name}:${signature}」を使用しています
% を削除すると (およびスペースを削除すると)、魅力のように機能します。%2520 で % char をエスケープしようとしましたが、うまくいきません。
Authorization ヘッダーは次のように計算されます。
canonicalized_headers="x-ms-blob-type:BlockBlob\nx-ms-date:${date}\nx-ms-version:2019-07-07\n"
canonicalized_resource="/${account_name}/${container}/${key}"
string_to_sign="PUT\n\n\n${content_length}\n\n${contentType}\n\n\n\n\n\n\n${canonicalized_headers}${canonicalized_resource}"
decoded_hex_key="$(echo "$azure_key" | openssl enc -base64 -d)"
signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac HMAC -macopt "key:$decoded_hex_key" -binary | openssl enc -base64)
curl -vvv -g -k --limit-rate "${rate_limit}" --proto-redir =https -X PUT -T "${file_name}" \
-H "x-ms-date: ${dateFormatted}" \
-H "${version}" \
-H "${blob_type}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: SharedKey ${account_name}:${signature}" \
"https://${endpoint}/${container}/${key}"
スペースの代わりに %20 を入れるとkey
、403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature
私は blob_type=x-ms-blob-type:BlockBlob version=x-ms-version:2018-03-28 を使用しています (バージョン 2019-07-07 も試しました)
どんなリードも高く評価されます、ありがとう!