How to upload files with media.upload in REST API?

Cool, so the response header should have the X-Goog-Upload-URL url to which you’ll make your second request

2 Likes

If you’re using multipart/related, then specifying the upload protocol as “multipart” is required for the File API. (Most others don’t tend to need it, but I’ve seen documentation about it.)

If you’re doing resumable uploads (which is the method you’re suggesting) and not multipart/related, then you don’t want it.

I know at one point when I was trying to get my implementation to work, it kept giving me the error that displayName wasn’t a valid field. So I gave up. {: Certainly could have been something else I was doing wrong at the time, so maybe I should revisit that.

Yes multipart was not required I got It working without sending the query as multipart.

I’ve got name working! I don’t really know why it works now, maybe it’s because of the API updates or just because I had forgotten to add the “files/” prefix in my past attempts. Just make sure you prefix the file ID with “files/” like: files/abcdefg

1 Like