I am trying to upload a file into my amazon account using the dojo.io.send.However, it's failing to do so .
This is error which i get to see when i run through the firebug.
<Error>
<Code>InvalidArgument</Code>
<Message>Bucket POST must contain a field named 'key'. If it is specified,
please check the order of the fields.</Message>
<ArgumentValue></ArgumentValue>
<ArgumentName>key</ArgumentName>
I figured out the reason and apparently the "Key" field is below to the "File" field because of that it is ignoring below ones and throwing up the error .
In order to rectify this issue, i need to have dojo.io.send() to send the param's list in the following way:-
key uploads/${filename}
AWSAccessKeyId
policy
signature
Content-Type plain/text
file
I tried my luck by playing with the below code but it always put the file field on the top.
I would appreciate if anybody can help me out in changing the sequence.
Code Snippet:-
var jsonpArgs =
{
url: "https://s3.amazonaws.com/<Bucketname>",
form : dojo.byId("Myform"),
//MyForm has an attribute
//as file which takes the file name from the user to upload.
handleAs: "json",
content:
{
"key":"*******",
"AWSAccessKeyId":"****",
"policy" :"***********",
"signature":"*******",
"Content-Type":"plain/text"
},
error: function(error)
{
},
};
dojo.io.iframe.send(jsonpArgs);
},
Appreciated,