question

konstantin-otixo avatar image
konstantin-otixo asked

Upload files

Hello! I have tried the api and there is a problem with uploading of the files. I did it by-the-book, like denoted here: https://developer.amazon.com/public/apis/experience/cloud-drive/content/nodes I tried to upload file in multipart mode, with the json object which describes the type (kind:file) and the name of my upload in the first part and the file contents in the other, using ApacheHttpClient. The problem is I every time got a bad request answer (400) from server.
amazon drive
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sean Callahan avatar image
Sean Callahan answered
Thank you for your post. It is tough for us to debug with such limited information. Please double check on the name of the parts. Our service expects you to name the first part “metadata” and second part “content” in multipart upload requests. If you need additional help, please email more details to clouddrive-api-support@amazon.com.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ruchir Godura avatar image
Ruchir Godura answered
Hi.. I am having the same problem... here is what my browser is sending (I am cutting/pasting from the javascript console window in Chrome. Can you tell me why I am receiving a 400 response {"message":"Cannot read from request."}? [Request payload below] -----------------------------7d3e8221-e9c6-4508-b959-be12fea81204 Content-Disposition: form-data; name="metadata" {"name":"my_file_name.png","kind":"FILE","parents":["Ne5B0DFyT4OlYOPSlsobBA"]} -----------------------------7d3e8221-e9c6-4508-b959-be12fea81204 Content-Disposition: form-data; name="content"; filename="file" Content-Type: application/octet-stream ðc 4 7 pjÎêê©wþ2 g*Wm úa ¦:Ð Y¬Ò ݱ7¤¦ÐB ... [rest of binary data deleted]
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ruchir Godura avatar image
Ruchir Godura answered
The response headers for the request that is failing (from my earlier message) are as follows: HTTP/1.1 400 Bad Request Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: http://api.knox.com:9080 Content-Type: application/vnd.error+json Date: Fri, 13 Mar 2015 16:06:33 GMT Server: Amazon-Cloud-Drive Vary: Origin x-amzn-RequestId: 8d80afb2-7d76-4035-b499-f245f112f900 Content-Length: 39 Connection: keep-alive
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ruchir Godura avatar image
Ruchir Godura answered
OK... I figured it out myself. The separator in the multipart form needs to have a '\r\n' at the end of each line, whreas my function was only sending '\n' You may want to clarify this in the documentation
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jamie Grossman avatar image
Jamie Grossman answered
Hey there, Looks like you found the answer before we had a chance to respond. Great to hear! We will investigate our documentation, so that it isn't as confusing in future. Thanks for letting us know. Jamie
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.