I am trying to upload an image to the azure blob repository, 2 days ago the code worked fine, but recently I get an error message that is not in the header of the required request. The following is the error:
"<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>MissingRequiredHeader</Code><Message>An HTTP header that mandatory for this request is not specified.\nRequestId:93cefc02-45af-41b0-9cb5-649d485faa49\nTime:2012-10-03T09:05:58.1982699Z</Message><HeaderName>x-ms-blob-type</HeaderName></Error>"
Let me explain the flow of the program. I am using nodejs server to create SAS from azure. This sas is then used by the Windows 8 client to install a specific file on blob storage.
function uploadFileAsync(uploadURL, file) { return new WinJS.Promise(function (complete, error, progress) { file.openAsync(Windows.Storage.FileAccessMode.read).then(function (stream) { makeBlob(file.contentType, stream).then(function (blob) { WinJS.xhr({ url: uploadURL, type: "PUT", data: blob, headers: { "Content-type": file.contentType} }).then(function (res) { complete(res); }, function (err) { error(err); }); }); }); }); } function makeBlob(contentType, stream) { return new WinJS.Promise(function (c, e) { var blob = window.MSApp.createBlobFromRandomAccessStream(contentType, stream); c(blob); }); }
uploadURL is the SAS from the node server.
I tried adding another header "x-ms-blob-type": "BlockBlob" with a PUT request, but alas, it is not needed !!
WinJS.xhr({ url: uploadURL, type: "PUT", data: blob, headers: { "Content-type": file.contentType, "x-ms-blob-type": "BlockBlob" } }).then(function (res) {
My team and I tried to download it from several installations, using the most basic (oldest) versions of our application that worked fine earlier. From this we came to the conclusion that something must change at the azure level. Please advise!
UPDATE: Finally, it worked again by adding the x-ms-blob-type header, this time doing the trick. Fiddler really was a big help, thanks to Gaurav ...
However, using Fiddler showed me some things that are still unclear.
1) The following is the request and response filmed by a violinist
Request: PUT /dummy/Content/dummy.bmp?st=2012-10-06T06%3A53%3A49Z&se=2012-10-06T07%3A53%3A49Z&sr=dummy&sig=dummydummyNQ4%3D HTTP/1.1 Accept: */* Filename: dummy.bmp Content-Type: image/bmp x-ms-blob-type: BlockBlob Method: PUT UA-CPU: AMD64 Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0) Host: dummy.blob.core.windows.net Content-Length: 85414 Connection: Keep-Alive Pragma: no-cache Response: HTTP/1.1 201 Created Transfer-Encoding: chunked Content-MD5: MdRpPr+eOePkjry2+6myQg== Last-Modified: Sat, 06 Oct 2012 06:57:45 GMT ETag: "dummyTag" Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-id: dummyide-f2defa18c095 x-ms-version: 2011-08-18
Should serviceVersion be 2012-02-12, because I didn’t specify it anywhere. Therefore, it should not be the last by default.
2) According to this page http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx x-ms-blob-type is an optional header, then why does it say mandatory?
PS: Adding all the REQUIRED HEADERS did not help. He still said the required header is missing (x-ms-blob-type).