Jump to content

Recommended Posts

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

 

Link to post
Share on other sites
  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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

Link to post
Share on other sites
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
Link to post
Share on other sites

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?

Link to post
Share on other sites
  • 2 months later...
  • Newbies

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By GAltanis
      Dear users,
      I have three tables for three relevant layouts. Each one has separate table and tables are related with only one field.
      The scope is to show on the 2nd and 3rd layout the records that related with the 1st one. Here are some screen shots with what I need to do. Actually, I need to have on the seconf layout ("Orders from suppliers") the related records from the first one ("Suppliers list")
      Thank you thank you
      Giorgos

       

    • By epatrick
      I find it odd that FileMaker is so intuitive yet hides access to the file name of the data source during importing. It looks like the only way I have found based on posts on the forum is to import the Data Source file as a reference into a container field. That is an extra step that shouldn't have to be done since FileMaker sees the Source file name during multiple points in the import process. Here are three dialogs where it's seen during import. There has to be a way to use the input file name with some kind of Get Function.  Please help!

    • By 34South
      I previously used ODBC Manager (32 bit)  to great success importing data directly from Filemaker Server to JMP. I recently upgraded to Catalina (MacOS 10.15.5) and knew that one of the casualties would be this ODBC utility. I downloaded the 64 bit ODBC manager from Actual Technologies and successfully installed it but get the following message when trying to open an FM database from within the ODBC interface in JMP:
      dlopen(/Library/ODBC/FileMaker ODBC.bundle/Contents/MacOS/fmodbc.so, 6): image not found
      I have navigated to Actual Technologies' web site believing I should download an ODBC driver but this comes at a hefty price tag, especially when converted to my local currency. Given the increasing costs of maintenance contracts and SSL certificates I had hoped to avoid further expenditure. Do I really need this and is there an alternative?
    • By droid
      I've been saving various files - mostly pdfs - in FM container fields, for years. A script triggered by clicking in the field allowed the field to be exported for viewing.
      Recently I upgraded to FM18, and now when I click in the field, I'm told "container fields cannot be exported"!
      Is there a new way that I should be doing this? Thanks.
    • By ggt667
      I can ping my PDF document server from Terminal, I can connect to the PDF document server from all browsers apart from Safari, my default web browser is FireFox, I also tried to change to Chromium and Opera as the default web browser. WebViewer has the same symptoms as Safari, server not found.
      $ ping -nc 1 document PING document (10.0.0.7): 56 data bytes 64 bytes from 10.0.0.7: icmp_seq=0 ttl=64 time=0.002 ms --- document ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.002/0.002/0.002/0.000 ms FileMaker says ’Couldnot connect to the server.’
       
      The issues is easily solved by creating a new MacOS X user, and log in to that user, however I would rather like to fix the current user not having to migrate all other application settings. Is there some dns cache specific to Web Viewer and Safari?
  • Who Viewed the Topic

    6 members have viewed this topic:
    DODO  Mark Pastoril  bcooney  Ocean West  comment  jbrown 

×
×
  • Create New...

Important Information

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