Av Rolf

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.


2018-08-13 Fabian

I'm currently using 360's FTPeek to upload to FTP. I will try this out!

My users get nervous about auto-sending FTP from Filemaker. How about showing the FPT file list in a web viewer so they could see it is uploaded correctly, is that doable?

2018-08-13 Rolf

Web viewer might be an option. Easier though to use cURL once more with the param "-l" which returns a list of all files in a folder, like:

Insert from URL [$$ftp;

You might show the file names you will get in $$ftp in a card window, using the same technique as described here https://www.filemakerbloggen.se/post/postadresser-med-api/

2019-02-19 Damaris Schnieders

Juѕt what I was looking for.

2019-08-12 Fabian

Thanks Rolf!

Took another year, but now I made a file-list based on this. :)

By the way, can Filemaker's cURL options handle the various layers of security in sFTP as well as FTPS in these GDPR-days?

I suspect FTPS would just be changing to "sftp://", while sFTP must handle public (and possibly private) key.

2019-08-12 Rolf

Insert from URL has support for http, https, ftp, ftps, file, smb, smtp, smtps, ldap and ldaps. No sftp.

2019-08-12 Fabian

Too bad. I have problems doing sFTP with 360's FTPeek (personal key, the simpler security works) , but I'll look into BaseElements before I give up, as I don't really like the team to handle this manually. If I find a solution, I'll keep you posted.

Skriv en kommentar

Din epost-adress stannar hos oss.