0 Replies Latest reply on Sep 24, 2012 7:36 AM by grace-glory

    How to form CanonicalizedAmzHeaders in Flex

    grace-glory Level 1

      Hi All,


      I'm using query string to download file from amazon s3 to Flex application however want to  show prompt message to user to go "Open" or "Save" dialog box. Amazon docmentation proposed to use CanonicalizedAmzHeaders.  I have created tosign using below code,



      private function getAuthenticationString_Test(verb:String,
                                                            contentType:String = null,
                                                            hash:String = null):String
                  var toSign:String = verb + "\n";
                  toSign += (hash != null) ? hash + "\n" : "\n";
                  toSign += (contentType != null) ? contentType + "\n" : "\n";
                  toSign += dateString + "\n" + resource;
                  toSign += "\n" + "response-content-disposition:attachment"
                  //toSign += "\n" + "x-amz-headername:response-content-disposition=attachment; filename=file.png;"
                  //"response-content-disposition=" . "attachment; filename={$filename}"
                  var toSignBytes:ByteArray = new ByteArray();
                  var hmacBytes:ByteArray = hmac.compute(secretAccessKeyBytes, toSignBytes);
                  return Base64.encodeByteArray(hmacBytes);


      however it throws signature is not correct because of "response-content-disposition". It just works fine in new tab without "response-content-disposition". Please help me.