DEV Community

Discussion on: Using Google Drive API v3 to upload a file to drive (in React)

Collapse
 
kevincassidy profile image
Kevin Cassidy

Hi Arnab,

Yes from what I can see I've followed your instructions - and the file does get uploaded - it just seems to be corrupt for some reason.

I've tried with an image and got the same result.

This is how it looks (I've tried making tweaks to what you provided but same result):

--foo_bar_baz
content-disposition: form-data; name="metadata"; filename="test.png"
content-type: application/json

{"name":"test.png","mimeType":"image/png"}
--foo_bar_baz
content-disposition: form-data; name="file"; filename="test.png"
content-type: image/png

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAJYCAMAAACJuGjuAAACdlBMVEUBCQMcHBIZHA8dGw0XGhAVGA4UFwwBBgICDAMDDwQSFgsPGA4eHA8QFAgXGQ0bGAweHBMOEgcXFwscHBAFEQYlHhQLFQsMEgYlHBIoHA4VFwkc.. etc
--foo_bar_baz--

And I get my response like so:
{
"kind": "drive#file",
"id": "13Htxa1Lcfk_VyDDtZPj0yYBrs2_zwO4u",
"name": "test.png",
"mimeType": "image/png"
}

Let me know if you have any ideas.
Thanks,
Kevin