我想使用傳統的ASP(無選擇!)上傳文件到Azure Blob存儲。不過,儘管我可以使用MSXML2.ServerXMLHTTP來列出容器內容,但我無法創建blob。我需要使用它來上傳PDF文件,所以我使用BlockBlob。如何使用傳統ASP將文件上傳到Azure Blob存儲?
我相信我無法正確創建授權密鑰。有沒有人有經典ASP VBScript中創建授權密鑰的代碼示例?我有類似下面的內容,但不知道如何在Classic ASP中生成密鑰。
' replace with your account's settings
' setup the URL
baseUrl = "https://<myaccount>.blob.core.windows.net"
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
PathUrl = baseUrl & "/test/myblob"
' setup the request and authorization
http.open "PUT", PathUrl , false
'How do I generate this key from the headers and path using HMAC-SHA256 and my prim/sec account key
http.setRequestHeader "Authorization", "SharedKey <myaccount>:?????"
http.setRequestHeader "Date", "2011-6-16 9:22"
http.setRequestHeader "x-ms-date", "2011-06-16 9:22"
http.setRequestHeader "x-ms-version", "2009-09-19"
http.setRequestHeader "Content-Length", "11"
http.setRequestHeader "x-ms-blob-type","BlockBlob"
http.setRequestHeader "Content-Type", "text/plain; charset=UTF-8"
postData = "hello world"
' send the POST data
http.send postData
' optionally write out the response if you need to check if it worked
Response.Write http.responseText
我得到錯誤AuthenticationFailedServer未能驗證請求。確保授權標頭的值正確形成,包括簽名。
感謝
格雷姆
聽起來像一個很好的計劃。我不喜歡在ASP中執行計算。 – GraemeMiller 2011-06-16 16:18:37