FileMaker 16 - Uploading files to Dropbox

Integrating third party APIs can be a bit daunting when you’ve never worked with them before. Fortunately, the most difficult part of the process is simply taking the time to research the API and implement the features you’d like to have.

When you’re working within FileMaker, you’re often capturing content which may need to be pushed into another online location - such as Dropbox. If your FileMaker solution needs this, then adding FileMaker Dropbox integration is the way to go.

With FileMaker 16, you can now use the native cURL functionality in order to directly upload a file into a designated Dropbox account. Once you’ve made the connection with Dropbox, you can pretty much do anything you’d like to your dropbox account.

AttachmentSize
UploadingToDropbox.zip262.81 KB
Tags:

Comments

Ok, Matt - I tried out the techniques here and they worked perfectly! I need a bit more guidance, however. Here’s my situation. This will be a long post, hopefully what I have found out and the answers you might be able to add will prove helpful to others.

I have a FM Go 16 (soon to be 17, I hope) solution that is an anesthesia electronic medical record (we call it OSAEMR, for Open Source Anesthesia Electronic Medical Record). At the end of the anesthetic, the user can choose to print out a pdf report containing the reports of their choosing.

I have a printing script that sucks one copy of this pdf back into the file (to be reviewed later if desired), and also puts another copy into the FM Go file area, so they can use the Select button, select a bunch of the files, and upload them or whatever.

Using the techniques you describe in the video, I was able to make the script also upload the pdf into a new Dropbox folder created in my Dropbox account -

My Dropbox Account/Apps/OSAEMRtest/createdpdf.pdf

(OSAEMRtest is the name of the Dropbox “app” I created. )

As I said - it worked perfectly- for me. I did it by generating a token at the developer page based upon my Dropbox account

and pasting it into the DropboxToken custom function you describe and then into the script laid out in the example file. Wonderful, I was so excited!

If I can do this for my users, they will be able to automatically print and upload their anesthetic records directly into their own copy of my App Dropbox folder, which they can then share (in a HIPAA-compatible fashion, of course, using Dropbox Business and having a Business Associate Agreement [BAA] in place) with the facility and their biller. A _huge_ improvement for most CRNAs, who are now mailing and/or faxing this information.

I of course began investigating further into the Dropbox developer materials, but they all speak “Dropbox-ese”, and I’m a bit lost. Here’s what they said:

"In order to have other users connect their own Dropbox accounts, you should implement the OAuth 2 app authorization flow in your app. There's a guide here that explains how that flow works:

https://www.dropbox.com/developers/reference/oauth-guide

You can find the documentation for it here:

https://www.dropbox.com/developers/documentation/http/documentation#authorization

(If you're using an official Dropbox SDK though, refer to the specific documentation for the SDK, as it will do most of the work for you.)

Once that's implemented in your app, you can distribute your app to them to have them use it and connect their Dropbox accounts.

Each access token is for a specific app-user pair, and allows access to that user's account, to the extent allowed by the app's permission. You should not distribute your own access token to end-users. Each end-user will get their own access token via the app authorization flow."

Here are my questions, based on this explanation from the Developer materials:

"The general idea is that the user will be redirected to Dropbox to authorize your app to access their Dropbox data. After the user has approved your app, they'll be sent back to your app with an authorization code. At this point your app will exchange the authorization code for an access token which can be used to make subsequent requests to the Dropbox API"

So - I’m thinking I need to set up a web viewer next to a button (“click here to go to Dropbox and sign up for the OSAEMR App”) that allows my users to log on to Dropbox inside the web viewer and request a token for my app.

Dropbox will then send back some type of URL containing the token, which I then parse and put the token into a field (could I insert it into my DropboxToken custom function somehow?). How does my app “listen” and receive the returning URL containing the token? This part is way beyond my understanding.

Once I figure out that part, OSAEMR will be AMAZING! ;>)

Thanks for any help,

Dan

(PS: I am posting a version of this to the FileMaker Developer community also)

Dan Simonson
Dsimonson@mac.com

Ok, I figured out how to use a web viewer in my solution to take the user to Dropbox to allow them to authorize my Dropbox "app" so they can save files to it.

All I needed to do was create a web viewer on the layout and, in the Web Address, put the following:

https://www.dropbox.com/oauth2/authorize?client_id=<my_dropbox_app_key>&...

The variable <my_dropbox_app_key> is obtained from the App Console page for my Dropbox App. Note that it does not have quotes around it!

When the user goes to the layout, the web viewer fires up and they are taken to the Dropbox website to sign in (unless they are already signed in). Once they sign in, they are taken a page giving them the opportunity to authorize my app.

When they click/tap the button, because I did not include the redirect_uri parameter in my GET url, instead of passing back the authorization token in the response, it takes the user to another page (still within the web viewer) that displays the token (code) text they can copy and paste somewhere.

The reason I did not include the redirect_uri parameter is because I don't know what would happen. What URL should I use? I have to put it into the "Redirect URIs" field on my Dropbox App page, but I don't understand what URI to use. The example has this:

https://www.example.com/mycallback?code=<authorization code>&state=<CSRF token>

I'm going to ignore the "state" variable, but boy do I need that <authorization code>! My goal is to put it into a field somewhere in the user preferences, and use it in my script that uploads my pdfs to the Apps/OSAEMRtest/ folder on the user's Dropbox account.

So - any ideas on what to put in my redirect_uri? Obviously I would like something returned to my webviewer that I can then parse to get the response code instead of having to have the user copy and paste it in to a field, but I'm stuck here.

Dan Simonson
Dsimonson@mac.com

Hello Matt can this be achieved with Microsoft OneDrive.
I'm retired and use filemaker v. 19 now as a pass time.
I love the way you teach. Keep up the good work.