Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 1514 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

I am novice filemaker developer, and trying to learn the cool ways Filemaker can integrate with other apps.

The "simple" task: upload document (.pdf) to Google Drive Folder with native filemaker funtions (no plugin).

So far: I have managed to get the authorisation token (following Seedcode guide for Gmail integration and Harmonic DevCon18 presentation and demo files) and make the POST call to create a file in the Google Drive root folder, however the file is unreadable. So my guess is that I am not putting all the curl options correctly from what I understand from the Google Drive API documentation ( https://developers.google.com/drive/api/v3/manage-uploads😞

POST https://www.googleapis.com/upload/drive/v3/files?uploadType=media HTTP/1.1
Content-Type: image/jpeg
Content-Length: [NUMBER_OF_BYTES_IN_FILE]
Authorization: Bearer [YOUR_AUTH_TOKEN]

[JPEG_DATA]

My script steps are as follow:

Set Variable [ $file ; Value: google_api::file_upload_v2 (container)] 
Set Variable [ $length ; Value: GetContainerAttribute ( google_api::file_upload_v2 ; "filesize" ) ] 

Set Variable [$curlOptions;
"-X POST"
&" -H \"Content-Type: image/jpeg"
& " -H \"Content-Length: " & $length & "\""
& " -H \"Authorization: Bearer "  & API_tokens::access_token & "\""
& " -d @$file" ]

- - - - - - - - - 

Any guidance would be much appreciated! thanks a lot in advance for your valued time.

Luis

 

Posted

Hello,

I have edited my curl following the advise from other users in a different forum and looks like this:

"-X POST"
    & " -H \"Authorization: Bearer "  & API_tokens::access_token & "\""
    & " -H \"Content-Type: multipart/related; boundary=foo_bar_baz\""
    & " -H \"Content-Length: 119\"" & Char(13)&Char(10)
    & "--data-binary \"--foo_bar_baz" & Char(13)&Char(10) &
    "Content-Type: application/json; charset=UTF-8" & Char(13)&Char(10) &
    "--data-binary @$metadata" & Char(13)&Char(10) & Char(13)&Char(10) &
    "--foo_bar_baz" & Char(13)&Char(10)
    & "Content-Type: image/jpeg" & Char(13)&Char(10) & Char(13)&Char(10)
    & "--data-binary @$file\"" & Char(13)&Char(10)
    & "--foo_bar_baz--"

But Still I get the Malform multipart body...

Any suggestions how to fix this?

Thanks a lot,

Luis

Posted

Is the Content-Type correct?

If this is PDF should it be application/pdf?

Posted (edited)

 

4 hours ago, IdealData said:

Is the Content-Type correct?

If this is PDF should it be application/pdf?

Hi many thanks for your input.

I reviewed the code and the $metadata is json = {"mimeType":"image/jpeg","name":"file.jpeg"}

I am just trying to upload first a jpeg file on multipart POST, this is with the name and the type of file (extension). I found two articles in stackoverflow that first suggested to put the "char(13)&char(10)"  after each line inside the body, but I think I am not putting them in the correct place because as I play around I get errors. I am pretty sure it is about one " that I am not properly formating... but cant figure out what it is.

While there are plenty of demos out there for other Google Services, I wonder why I havent been able to find any tutorial for Google Drive, could it be that it cant be done without Plugin?

Thanks a lot to the community for any feedback :)

Luis

Edited by docasar
Posted

All of the curl commands require a space before them so,

& "--data-binary @$file\"" & Char(13)&Char(10)

should be

& " --data-binary @$file\"" & Char(13)&Char(10)

I'm not convinced you need the CR/LF pairs.

Also, have you tried running the curl command manually - from the command prompt?

  • 2 months later...
  • Newbies
Posted

Hi Docasar!!  What an interesting post... and EXACTLY what 'm trying to achieve as well.

Did you have any luck with this solution?  Were you able to connect FM to GoogleDrive?

I'd really like to save PDFs into a GDrive shared folder.

Can you share a sample file?  It would be HUGELY appreciated!!!

 

Cheers Tanya, from NZ

  • 3 months later...
Posted
On 6/16/2020 at 12:05 AM, TarnimoNZ said:

Hi Docasar!!  What an interesting post... and EXACTLY what 'm trying to achieve as well.

Did you have any luck with this solution?  Were you able to connect FM to GoogleDrive?

I'd really like to save PDFs into a GDrive shared folder.

Can you share a sample file?  It would be HUGELY appreciated!!!

 

Cheers Tanya, from NZ

Hi Tanya, I am sorry for the late reply... did you manage to do it? I put it on hold due to how difficult it was, but I found a workaround I need to try again.

Best regards,

Luis, from Spain

This topic is 1514 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.