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


  • Who Viewed the Topic

    2 members have viewed this topic:
    Lee Smith  Wang 
  • Similar Content

    • By troi
      Encryption plug-in adds new script steps and online help for FileMaker Pro 16.
       
      Alphen aan den Rijn, Netherlands, August 15, 2017–Troi today announced the immediate availability of Troi Encryptor Plug-in 4.0 for FileMaker Pro 16.
       
       
      What is Troi Encryptor Plug-in?
       
      Troi Encryptor Plug-in is a very powerful tool for securing your FileMaker data, exporting or emailing your data without risk and importing safely back into FileMaker. All from within FileMaker you can:
              
      - encrypt text or container fields, using the powerful 256-bit AES encryption scheme, so that your sensitive data is secure
      - export encrypted data that can be sent safely across internet, for example via email. No risk that someone will read or change the data while in transit
      - use the decryption functions to restore the original information after you have imported the received email or export file back into FileMaker, with the assurance that nobody will have tampered with it
      - exchange AES-encrypted data with other systems (like for example PHP-mcrypt)
      - verify data integrity and sources with SHA-1 message digests
      - encode text in Base64
      - make conversions to and from binary
      - compress databases with large text fields
      - save and retrieve passwords to and from the keychain of the operating system
       
      What is new in version 4.0?
       
      We rewrote Troi Encryptor Plug-in for FileMaker 16 and it now has the following new functionality:
              
      - Tested and made compatible with FileMaker Pro 16.
      - Fixed several bugs, rewrote and modernized the code in several places and made further improvements.
      - Updated the User Guide and the Reference.fmp12 file.
      - Made various minor changes to the example files to better work with FileMaker Pro 16.
      - Updated the code by adding improved namespace handling to make the plug-in more robust.
       
      Extra features when running FileMaker Pro 16
       
      Version 4.0 adds the following new features when running in FileMaker 16:
              
      - The Encryptor Plug-in adds multiple script steps when running in FileMaker Pro 16. You can select these script steps in the script steps pane in Script Workspace, or you can begin typing the script step name, then choose the script step from the list that appears. The script steps expand the possible actions you can perform with FileMaker Pro. Only steps that perform an action have been added as a script step. Functions that just manipulate data and have no side effect (like for example Encr_EncryptRijndaelAES) are only available as an external function.
      The following three script steps are added:
         - Save Password to Keychain
         - Get Password from Keychain
         - Delete Password from Keychain
      - Added new scripts to the EncryptAES example file, which demonstrate how to use the new external script steps of FileMaker Pro 16. The examples check if FileMaker Pro 16 is running and will select these new scripts.
      - Added support for online help for the functions and script steps of the plug-in. You can now easily get online help from the Troi website, by clicking the Help button (the small question mark button) next to the function description in the functions pane or the script step description in the script steps pane.
       
      Apart from these additions we fixed several bugs and made various further improvements. More detailed information on all changes and improvements implemented in Troi Encryptor Plug-in 4.0 can be found at: https://www.troi.com/products/encryptorplugin/
       
       
      Pricing & Availability
       
      A fully functional demo version of Troi Encryptor Plug-in 4.0 is available for downloading at: https://www.troi.com/products/encryptorplugin/
       
      Licenses cost US$ 79 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.
       
       
      Upgrade information
       
      Version 4.0 needs a new registration. The upgrade is free for users who bought a license for Troi Encryptor Plug-in on or after July 5, 2016. Eligible users will be sent a new registration. Contact us if you have not received yours after August 18, 2017.
       
      Upgrades from licenses bought before July 5, 2016 are available from US$ 39 per user. Upgrade prices for other licenses can be found on our web site. You can order upgrades from our web site.
    • By 123
      Hey,
      I have a question about hosting my filemaker database. If I buy a license for 5 people form here: https://store.filemaker.com/filemaker-cloud , will I also need to purchase 5 normal FileMaker 16 Pro Client licenses so people can actually connect to the database? I don't quite understand how this works yet, maybe someone can help me out. Do I get the client licenses with the purchase of a server license? I need 5 people to be able to access it. Thanks in advance,
      Mike
    • By 123
      Hey,
      I have the following problem. I'm working on a solution for the owner of several restaurants. Each restaurant has meetings once or twice a month. How would I structure the tables so that I could have a layout on which I select a restaurant and then inside a portal I get a list of all employees. On the portal for each row I want to have a button or checkbox to mark if an employee is present or not.
      I already have the following tables:
      Restaurants, Employees and Meetings
      So far I have a relationship between the Restaurants and Employees table which I use to assign employees to a restaurant, and a relationship between the Meeting and Restaurant table, which allows me to show all employees that work at a selected restaurant using a portal on the meetings layout. How do I proceed to solve my problem? Do I create another table MeetingAttendees or something similar that I use to keep track of people attending a meeting? How would I create a relationship then to allow me to mark certain employees as present and absent?
      Thanks in advance,
      Mike
    • By TJ53
      On a separate thread I asked Bruce Robertson if the new FM16 JSON functions could be used together with the virtual list technique he created. I haven’t experimented with it but I wonder if JSON adapt well to this great technique. Any thoughts? thanks!
    • 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. 
×

Important Information

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