This site uses tracking cookies. By using this site, you agree to our Privacy Policy. If you don't opt in, some parts of the site might not function.
Blog
Home / Blog / FileMaker / FileMaker 16: cURL and Container Fields
15May 2017

FileMaker 16: cURL and Container Fields

About the Author

Mike Duncan Mike Duncan

Mike is an AWS Certified Solutions Architect as well as a certified FileMaker Developer. In addition to his work, Mike also enjoys pursuing his art, freelance writing, traveling, and spending time with his family.

Comments (11)

Martin G - July 31, 2017

Hi Mr. Duncan, thank you for this post; I found your solution really useful. Quick question though – what about multiple files, is that achievable in a single “InsertFromURL” command?

Reply
    Mike Duncan
    Mike Duncan - August 3, 2017

    I have not tested this, but I can’t think why this would not work.

Martin Spanjaard - September 6, 2017

Hi Mike,

Thank you very, very much for this post. Specifically the fact that the file variable has to be in between the quotes. For an old fashioned FileMaker developer who knows little of http Post and cURL this was not imaginable without your help.

Some remarks or questions.
– Should the -F in: -F “file=@$myFile” not be within the quotes, as in: “-F file=@$myFIle” ?
– In my case I had to post data in csv format. The data are gathered in a script in a loop into the variable $data, just before the Insert from URL. As all the help texts and explanations talk about uploading ‘a file’, I thought that I should give the file path in the Insert from URL. After a lot of trial and error I understood that in my case the ‘file’ is the data itself. So, in the script the variable $data is used in the Insert from URL as in:
“-F file=@$data”.
Do I misunderstand the use of the word ‘file’ here? Could it be a path to a file, or should it always be the content of a file? (If you understand what I mean.)

Reply
    Mike Duncan
    Mike Duncan - September 11, 2017

    In this example, “file” is just the name of the parameter that gets passed. Similar to “name=Martin” where “name” is the key and “Martin” is the value. Of course you would need to adjust according to the requirements of the web service or script you were submitting to.

Brent Durland - March 7, 2018

Nice article! I’ve been playing with this as well, with a Dropbox integration. In this case the curl options include a line like this:

–data-binary @$file

And I set the $file variable to the contents of a container. In this case I don’t need quotes around the variable.

You can play with this file here:

http://www.filemakerforever.com/articles/133

Reply
mcarrgomm - April 21, 2018

Hi Mike,

I’m looking to hopefully take this solution one step further. Is it possible to use FileMaker’s new cURL functionality to upload say a jpg file in the container field up to a bucket on my Amazon S3 account? and if so, do you have any pointers on the calculation formula to use when specifying the cURL options?

Reply
    Mike Duncan
    Mike Duncan - May 9, 2018

    Possible? I think so, but AWS uses a header signature that is non-trivial to create, and is different for each service. I am actually working on that now, and can share when done. Usually you might use a SDK to do the heavy lifting for this part, but with cURL options, have to build it all yourself.

akim - July 7, 2018

Mike,
Thank you for your great insights into avoiding the issues of uploading files, via FMP’s Insert From URL command.
Your solution was quite creative!
I however found that your coding of literal terms might cause a problem, should the container file name or its table name change.

I added the following lines to keep the names as references rather than as strings.

Go to Field [Table::UploadField_r]
Set Variable [$TableName_DoubleColon_ContainerFieldName ; Value:Get ( ActiveFieldTableName ) & “::” & Get ( ActiveFieldName )]
Set Variable [$null; Evaluate ( “Let ( $” & $myFileName & ” = ” & $TableName_DoubleColon_ContainerFieldName & ” ; \”\” )” )]

After that the command to Insert From URL will have an active reference to post, and less likely to error on not finding a document or other data to upload, due to a static name.
I’d appreciate your thoughts on this, considering that your creativity has brought us all this far.

Reply
    Mike Duncan
    Mike Duncan - July 9, 2018

    Sure, and I have seen others use custom functions to abstract table and field names. In presenting the technique, I hope it is easy to understand, and if this abstraction is needed it can be added. Thanks for you input!

Johan Sundell - March 21, 2019

Think you can use the filename to tell the remote server what you named the file, from the curl manual

“You can also explicitly change the name field of a file upload part by setting filename=, like this:
curl -F “file=@localfile;filename=nameinpost” url.com”

Reply
    Mike Duncan
    Mike Duncan - March 21, 2019

    This is right, but may be dependent on the server, and what is handling the file on that end. You mileage may vary 🙂

Leave a Reply