2018

Jun

17

Av

The Insert from URL script step was enhanced in version 16 with cURL, a utility for transferring data in different ways. One function not available in earlier versions of FileMaker is FTP transfer. Four years ago I wrote about uploading photos from FileMaker Go using web services, in this article I use the same sample but now using FTP.

cURL has a lot of options, (and it is originally developed in Sweden!), but not all of them are implemented in FileMaker. One option is to transfer files using FTP. Before version 16, FTP was only possible using an external plugin. But cURL is working perfectly well even in FileMaker Go. In this small sample I am going to use the camera function in FileMaker Go and upload a thumbnail to a web site using FTP. It is an easy way to publish images, or actually any other information, to a web site.

FTP is short for File Transfer Protocol but in this case you actually don’t need a physical file. I first use a Set Variable script step to assign a variable a thumbnail version of the image, I will only have the image in a variable, $file.

The script for uploading is short:

Set Variable [$file; Value: GetThumbnail (Images::image; 400; 400)]
Insert from URL [$$ftp; 
"ftp://WEBSERVER/WEBSITE/public_html/uploads/img_" & Images::id & ".png"; 
"--upload-file $file --user USERNAME:PASSWORD"

The second line in the Insert from URL script step is the URL. The URL starts with the protocol used (ftp) and then the file path including the filename. The filename in my sample is ”img_NNN.png”, where NNN is the id of the FileMaker record.

The third line is the cURL options. I am using ”—upload-file $file”. The variable $file should be in the text string. To be able to upload I need to provide credentials with the —user option.

The iPhone app is looking almost the same as four years ago:

After uploading with the Upload button, it will take less than a second (depending on the internet connection of course), the resulting web page shows the uploaded image.

If it of some reason doesn’t work there are a couple of useful option for cURL. Add the following options to cURL:

 "--trace-ascii $$trace --dump-header $$dump"

You will get a call trace in $$trace and a dump of the result in $$dump. Display them in the Data viewer, or in the layout.

Skriv en kommentar

  • (will not be published)

Läs också: