我想使用传统的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