1

I am using signed urls to upload blobs from mobile devices using Air.

I have two questions:

When uploading blobs using a signed URL I assume I don't need to include all the headers as described in the documentation. Am I right in thinking that I simply need to do a PUT request to the URL and include the file encoded into the body with the Content-Type set to multipart/form-data; boundary=[[boundary here]]?

var client:HttpClient = new HttpClient();
var request:HttpRequest = new Put();
request.body =  UploaderPostHelper.getPostData( filename,  byteArray);
request.contentType = 'multipart/form-data; boundary=' + UploaderPostHelper.getBoundary();
client.request(new URI(signedUrl), request);

http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx

(Source code for UploadPostHelper is here https://code.google.com/p/as3asclublib/source/browse/trunk/net/UploadPostHelper.as)

And secondly, can I specify that I want to do a PUT request using a POST request and a header?

Cheers.

Tom
  • 12,591
  • 13
  • 72
  • 112

2 Answers2

4

When uploading blobs using a signed URL I assume I don't need to include all the headers as described in the documentation.

You would need to specify 2 headers - Content-Length and x-ms-blob-type. I'm assuming you're saving the files as block blobs so the value for x-ms-blob-type should be BlockBlob.

Also the Content-Type should be the content type of the file e.g. plain/txt, image/gif etc.

And secondly, can I specify that I want to do a PUT request using a POST request and a header?

Not sure about this one. The HTTP method of your request should be PUT.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Ok cheers, the issue is that from ActionScript / Air, you can only do GET or POST methods unless you use 3rd party libraries which are buggy and not well maintained. – Tom Sep 17 '13 at 10:13
  • I didn't know about it. I just did a quick search and landed on this question on SO: http://stackoverflow.com/questions/3641148/how-to-send-put-http-request-in-flex. See if the answer there helps you. – Gaurav Mantri Sep 17 '13 at 10:25
2

x-ms-version, Authorization, Date or x-ms-date, Content-Length and x-ms-blob-type are all required for the PUT operation. Content-Type is optional.

See http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx.

perplexed
  • 422
  • 4
  • 12