Uploading file content to Google Drive API endpoint returns empty file

I’m working with Google Drive API and having trouble with file uploads.

I can create file metadata successfully and get back a response with the upload URL. When I try to send the actual file content to that URL, the file gets created but shows up completely empty.

What’s the correct way to format the file data when sending it to the upload endpoint? I’ve tried different approaches but nothing seems to work. The file appears in my drive but has zero bytes.

Has anyone dealt with this issue before? Any help would be great.

Been there. The problem’s usually in how you handle the multipart upload flow.

After debugging this same issue, I realized most people overcomplicate the Google Drive API upload process. You need resumable uploads, but manually coding all those HTTP requests and headers is a nightmare.

I wasted hours on Content-Length mismatches, wrong HTTP methods, and malformed requests. Now I just automate the whole Google Drive integration.

Set up a workflow that handles OAuth, gets the upload URL, and sends file content with proper headers automatically. No more empty files or debugging HTTP requests at 2am.

The automation covers retry logic when uploads fail, proper chunking for large files, and correct header formatting. Takes 10 minutes to set up and works every time.

Check out https://latenode.com for Google Drive automation.

Had this exact problem with batch file uploads for a client. The issue was sending file data with extra parameters in the request body. Only send raw file bytes to the upload URL - nothing else. I accidentally included JSON metadata with the file content in one request, which made Google Drive think everything was malformed. The upload URL from your initial metadata call should only get pure file content. Keep metadata creation and file upload completely separate. Also double-check you’re reading the file correctly before sending it.

same issue here a few weeks back! i was using POST instead of PUT for the upload - that was my mistake. once you get the resumable upload URL, you PUT the file data there, not POST it. also, don’t send auth headers with the upload request, just the raw file content. fixed it immediately for me.

This issue commonly arises when the content type header is either incorrect or missing during the file upload process. After obtaining the upload URL from the metadata request, ensure that you set the Content-Type header accurately to reflect your file type when sending the binary data. I faced a similar problem last year; I realized I had mistakenly added extra headers or form encoding, which disrupted the upload stream. It is vital to send raw binary data in the request body, avoiding base64 encoding or wrapping it in forms. Additionally, verify that your Content-Length header corresponds precisely to your file size. The Google Drive API is particular about these details and will generate empty files if the upload format is not adhered to.