Forum Academy Marketplace Showcase Pricing Features

Uploading files to Google Drive - Drive API

Hi, there.
I am building an app that can upload files (pdf, png, jpg, docx, xlsx, pptx, etc.) to Google Drive.

I used the following Drive API for uploading.

When I sent the file as binary with Postman, the uploading succeeded and the file could be opened in Drive.

(But why is the file name “Untitled”?)

However, I can’t send binary by API Connector, right? I tried to send a file as form-data.

As a result, a response is returned, but the uploaded file cannot be opened in Google Drive.

googledrive_unsuccessful

(I did not set Content-Length because adding it would cause timeout.)

Is it possible to upload files from Bubble to Google Drive? Any advice would be appreciated.

Thanks.

Pretty sure when you upload a file you have to include its MimeType. I can see you’re MimeType is wrong when you’re file is Uploaded. It should be “text/plain”.

Thanks for your reply.
Yeah, I tried to upload the file with Content-Type as text/plain, but the result was the same as when I set it as application/json.

Both examples I see you’re using “application/json”. It must be “text/plain” for that type of file.
I’m not sure otherwise.

Thanks for the reply.
I did not attach an image, but I have also checked with text/plain. The result is the same as when set to application/json.


Your data type must be a file as well

Thank you! I tried it and this is the result…

Okay. Try this:

{ "parents": [ "<folderId>" ] , "mimeType": "<mimeType>", "name": "<fileName>" }

Use “Content-type: application/json” in your header like you were doing, use JSON as data type.

Use RAW body type.

In properties that have been created below:
Add your mimeType “text/plain” value.
Add your folderID “drive folder ID” value.
Add your fileName “output drive file name” value.

Thank you for your reply.

Hey, we took a step forward!
I was able to create the file, but have the following problems

  • The file name is still Untitled.
  • Raw data is saved as the body of the text file like below.

I believe we want to use Raw-form data, so we can still send a file with the payload. Rather than just the body. Cause that’s what’s missing. There is no file.

1 Like

Thank you for the reply.
So are you saying that I should send the file using “Form-data” at the same time I send the code I just sent in the body type “Raw”? (Is that what you mean by “Raw-form”?)
If so, how should I use two body type in ONE API call?
I am a beginner, so I would appreciate it if you could let me know.
Thanks.

I this thread is helpful as are some others but there are no definitive solutions to this issue… I am also still struggling to get Google Drive to recognise the file type and include a name for the file… anyone else have insights to this… it is doing my head in and the Google Developer manuals are not that useful to an API novice :slight_smile:

DId anyone ever come up with a solution to this? I have tried multipart and media and they both show up as untitled in Google drive just as the OP said. May Google OAuth is working fine, but uploading files to Drive has proved elusive.

Ultimately, what I would like to do is upload a file with the file name that the user sets in Bubble… so I guess that means multipart OR doing it in two API calls. I am open to either at this point.