We have reset all users FileMaker related profile fields. Please take the opportunity to update your information,  this will provide background to members whom read your posts. Click here.

Jump to content

Recommended Posts

357manch    0

With the introduction of cURL options in FM16's Insert from URL script step I've been investigating the possibility of being able to save a copy of my FM solution directly to my Dropbox folder using the https://content.dropboxapi.com/2/files/upload element from Dropbox V2 API.

 

I've successfully created the access token to pass through as part of this step and the Insert from URL script step successfully creates the stated folder and file in my Dropbox.  However, the file size is always 0 bytes.  I've tried 2 different methods

 

METHOD 1

#Export a compacted copy of this file to Temporary Folder

Set Variable [ $file_path ; Get ( TemporaryPath ) & "Solution.fmp12" ]

Save a Copy as [ "$file_path" ; compacted ]

 

#Set my cURL options to variable

Set Variable [ $curl_header ;

"curl -X POST https://content.dropboxapi.com/2/files/upload \\" & ¶ &

"--header \"Authorization: Bearer " & PREFERENCES::Dropbox_AccessToken & "\"  \\" & ¶ &

"--header \"Dropbox-API-Arg: {\\\"path\\\": \\\"/DB2FM/Solution.fmp12\\\"}\" \\" & ¶ &

"--header \"Content-Type: application/octet-stream\" \\" & ¶ &

"--data-binary @" & $file_path ]

 

#Dropbox URL

Set Variable [ $dropbox_url ; "https://content.dropboxapi.com/2/files/upload" ]

 

#Make Request - Set to variable adn then format to JSON field

Insert from URL [ Verify SSL Certificates ; With dialog: Off ; $json ; $dropbox_url ; cURL options: $curl_header ]

Set Field [ PREFERENCES:Dropbox_JSON ; JSONFormatElements ( $json ) ]

 

 

 

METHOD 2

#Export a compacted copy of this file to Temporary Folder and then import to a container field

Set Variable [ $file_path ; Get ( TemporaryPath ) & "Solution.fmp12" ]  //note1

Save a Copy as [ "$file_path" ; compacted ]  //note1

Insert File [ PREFERENCES::Container ; "$file_path" ]  //note1

#Set variable following instructions on FileMaker website which states:

#  -  Direct file access is replaced with a FileMaker variable prefixed by the @ character.

#  -  To access a file, you can set the variable to a container field, which contains the file, then use that variable as the parameter of the cURL option.

Set Variable [ $container_path ; PREFERENCES::Container ]

 

#Set my cURL options to variable

Set Variable [ $curl_header ; 

"curl -X POST https://content.dropboxapi.com/2/files/upload \\" & ¶ &

"--header \"Authorization: Bearer " & PREFERENCES::Dropbox_AccessToken & "\"  \\" & ¶ &

"--header \"Dropbox-API-Arg: {\\\"path\\\": \\\"/DB2FM/Solution.fmp12\\\"}\" \\" & ¶ &

"--header \"Content-Type: application/octet-stream\" \\" & ¶ &

"--data-binary @" & $container_path ]

 

#Dropbox URL

Set Variable [ $dropbox_url ; "https://content.dropboxapi.com/2/files/upload" ]

 

#Make Request - Set to variable adn then format to JSON field

Insert from URL [ Verify SSL Certificates ; With dialog: Off ; $json ; $dropbox_url ; cURL options: $curl_header ]

Set Field [ PREFERENCES:Dropbox_JSON ; JSONFormatElements ( $json ) ]

 

 

 

JSON Response For Both Methods

 

I get the following JSON Response for both methods

{

    "client_modified" : "2017-05-16T11:22:47Z",

    "content_hash" : "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",

    "id" : "id:heJWQ1SWwJsAAAAAAcMWNw",

    "name" : "Solution.fmp12",

    "path_display" : "/DB2FM/Solution.fmp12",

    "path_lower" : "/db2fm/solution.fmp12",

    "rev" : "3a0412f00f58892",

    "server_modified" : "2017-05-16T11:22:48Z",

    "size" : 0

}

 

Any ideas as to why the file is created but with no content.  I've also tried this with a number of different file types (.png, .txt, .pdf) by manually inserting a file into the container and greying out the 3 steps marked //note1 above but the result is always the same.

 

Share this post


Link to post
Share on other sites

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


  • Similar Content

    • By Kent Searight
      I'm trying to get a token from an authorization server using cURL in Insert From URL. When I make the following request in Terminal
      curl -i -X POST -d 'username=myaccountname&password=mypassword' https://authserver.com/login
      I get the token back in the response header.
      Since FileMaker doesn't support the --include (-i) option I haven't been able to figure out how to get the response header with the token.  Anyone have any ideas on how to accomplish this?

      Thanks in advance!
      -Kent
      UPDATE:
      Okay, I figured out I can get a response header by using the option --dump-header and setting it to a variable. The only problem now is that the token comes from a redirect location and I'm only getting the response header from the original URL. I'll keep working on it but I'll be happy to get whatever advice anyone can offer in the meantime. 
    • By jaboda
      I was interested to read that FileMaker 16 now supports the ability to sign in with an HTTP POST.
      I was wondering if anyone had tested this yet?
      I'm looking at creating a custom login screen so any examples would be great. Thanks.
       
    • By troi
      Updated file management plug-in for FileMaker Pro 16 improves Drag and Drop function
      Alphen aan den Rijn, Netherlands, June 19, 2017–Troi today announced the immediate availability of Troi File Plug-in 9.0.1 for FileMaker Pro 16.
       
      What is new in version 9.0.1?
      Version 9.0.1 is a maintenance update of our plug-in for manipulating external files and folders directly from FileMaker Pro. In this version we fixed a bug with the TrFile_DragAndDrop function on Windows, which prevented drag and drop when running FileMaker Pro 16. We also improved the DragAndDrop.fmp12 example file: the calculation for the bounds of the three drag zones is now correct when running FileMaker Pro 16.
      To read what was new in version 9.0 please see: https://www.troi.com/news/file90_pr/
      More detailed information on all changes and improvements implemented in Troi File Plug-in 9.0.1 and earlier can be found at: https://www.troi.com/products/fileplugin/
       
      Pricing & Availability
      A fully functional demo version of Troi File Plug-in 9.0.1 is available for downloading at Troi’s Web site at: https://www.troi.com/products/fileplugin/
      Licenses cost US$ 99 per user. Details on developer licenses and multi-user discounts can be found on our web site. You can order licenses from our web site.
      Upgrading to version 9.0.1 is free and recommended for all users of version 9.0: version 9.0.1 works with the same registration as the 9.0 version. Users who bought a license for Troi File Plug-in on or after May 10, 2016 are entitled to a free upgrade to version 9.0.1. Eligible users have been sent a new 9.0 registration. Contact us if you have not received yours.
      Upgrades from licenses bought before May 10, 2016, are available from US$ 59 per user. Upgrade prices for other licenses can be found on our web site. You can order upgrades from our web site.
       
      Contact information
      D. Budding, Troi Automatisering
      Newsroom: https://www.troi.com/news/
    • By 123
      Hey,
      I started working with FileMaker a while ago and so far it's been pretty fun and fairly easy to learn because I worked with MySQL in the past. However, there are still a few questions I have. I'm used to having complete freedom when it comes to databases, because in Python or C++ for instance I would simply write my own queries and get whatever data I need, no matter if a database is related to another or not. Anyway, the flexibility is still what causes me some problems. I have the following problem.
      I'm working on an ERP (Enterprise Resource Planning) software for the owner of several restaurants. I need to have the following tables to start with:
      Restaurants Employees Jobs Visa Health Insurances Meetings Now, the person using the solution needs to be able to create as many restaurants, employees, jobs and meetings as they want and assign them to each other. For instance, Restaurant A is going to have 5 employees, Employee A, B, C, D, E and so on, and all these employees will have one or multiple (this is really important) jobs assigned to them. This process has to be flexible, so I can assign an employee to whichever restaurant and job I choose. You also need to be able to assign one or more visa to a job (and the assigned employee), the same goes for one or more health insurances. The next problem is about meetings. Each restaurant needs to be able to have meetings every once in while, which need the ability to keep track of employees that attend the meeting. So you should be able to select employees form a portal or card window (in FM16 for instance) and they will be added to another table MeetingAttendees or something similar. Again, this needs to be flexible so every restaurant can create meetings and check which employee is present. (I need to be able to create a layout to display the meetings and who has been present, if possible also to see who wasn't).
      Normally I would simply take the IDs and create tables that join these iDs together, however I'm not able to recreate this in FileMaker, if one relationship works, the other breaks for some reason. If anyone could give me a simple layout of what my database needs to look like, or if possible and not too much to ask an example in FileMaker. Your help is much appreciated.
      Thanks in advance,
      Mike
    • By crayfish
      I've been using Daniel Smith's JSON scripts from (http://www.modularfilemaker.org/module/json/) to parse JSON.
      It's worked quite reliably (thanks Daniel!), but I'm wondering if anyone has compared its parsing speed to MBS's JSON plugin or the new native Filemaker 16 JSON functions? I'm still on 15. I'm working with some larger JSON files that are taking a long time to parse and hoping for a faster solution.
      Any data on which option parses JSON fastest? Any disadvantages/advantages to each option?
      Thanks!
×