Sign in to follow this  
Followers 0

Upload Contents of Container Field to FTP (Mac OS / AppleScript technique)

5 posts in this topic

Hi All, 


I just thought I'd try to give back to the community that has given so much to me by writing a little tutorial. This technique is one I developed on Macs. Mac OS X has the curl command line tool as part of the default installation. Curl is like a web swiss army knife. You can fetch files, POST data, upload to or download from FTP servers etc... so it brings a lot of functionality to the table which isn't built into FileMaker. I make use of curl through the "do shell script" AppleScript command, which in FileMaker I use through the "Perform AppleScript" script step. Here's a simple 6 line script that lets you take the contents of a container field and upload it to an FTP site. Substitute your container field in the first and fifth lines and your FTP information in the $script variable to make it functional. This script could be extended by actually having variables for the FTP credentials/location too but I've kept it simple here just to demonstrate the technique.



set variable [$file_name; GetAsText(YourTable::YourContainerField)]

set variable [$path_temp; Get(TemporaryPath) & $file_name]

set variable [$path_unix; Middle($path_temp ; Position($path_temp ; "/" ; 1 ; 2) ; Length($path_temp))]

set variable [$script; "do shell script "curl -T " & $path_unix & " ftp://USERNAME:PASSWORD@FTP_HOST/FTP_DIRECTORY/" & $file_name &"""]

Export Field Contents [YourTable::YourContainerField; "$path_temp"]

Perform AppleScript [$script]




Share this post

Link to post
Share on other sites

This is fantastic, and so simple. It worked for me on the first try. I couldn't believe it. Thank you.


Share this post

Link to post
Share on other sites



The script as-is may not work since as of FileMaker 12 GetAsText(containerField) returns more than just the filename. You may have to look for and remove additional text such as "remote:"


Share this post

Link to post
Share on other sites

Wondering...Is there a Apple script replacement for Windows?


Share this post

Link to post
Share on other sites

Simple - and did just what it is supposed to do!


FMPro 13 allows easier extraction of the container file name, by using the GetContainerAttribute function:

GetContainerAttribute ( GetContainerAttribute ( sourceField ; attributeName ) and substituting "filename" for "attributeName".

Other attributes can easily be read, too, as listed here:


HOWEVER... I suspect that the "curl-T" command has problems with specific characters in the file name.

I have found that the script just hangs if the file name contains spaces, "&", or other such non-UNIX-friendly characters.

Is there a way to overcome this, and still preserve the original filename?


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
Sign in to follow this  
Followers 0

  • Similar Content

    • adding product images in invoices and estimates
      By Markus64
      I'm looking to add the picture from the products table to Invoices and Estimates tables.
      Not to successfully yet. 
      What am I missing?
      Thanks in advance for you insights. M.
    • calculation field (container) image not showing on FM GO
      By justakid
      Hi All,
      I created a calculation that resulted in a container image (see below). This is allows me to add/update images without doing anything in Filemaker.
      "imagemac:images/" & S_shot & ".png"
      This works perfectly on the my Mac, but doesn't work on FM go.
      The only way I could get the images to work in FM go was to import the images on a shot by shot basis. I imagine a script could be written to do this, but before doing so, I was wondering if anyone knew if there was a way to make the calculation work.
      Any ideas?
    • Filemaker Server Containor Locations
      By Yogi Bear
      We have just moved our FM CRM from being hosted on a P2P network to Filemaker server 14. Going forward we also want to attaché documents to clients.
      As these attachments might be large, it might be an idea to have them stored in an external container. There is a default container linked to the DB but I can't edit it or change the location. (See picture). Ideally I would like to specify a UNC path and have them stored in a separate folder on our Fileserver.
      1. Am I correct that there is no way to change the location, or am I missing something?
      2. Is there way to change the name of the path? i.e. the original DB name was invoices but now is called something else. Where do I look?
      3. What do other people recommend for storage of attachments? Our old CRM generated thousands of files totalling ~ 15Gb over 4 years.
      I just can't seem to find very much info on this topic on google. Feel free to to send me link
      Platform: Filemaker Pro 14 / FMS 14 running on Windows 2012R2
      Best regards, JS

    • Photos reduced in size by GetThumbnail appear to take up more storage on FMGo 14 than in OS X
      By folks
      I wonder if the storage for the images remains at the size of the original image taken by the iPad camera
      in spite of the replacement of that image by a much smaller thumbnail.  
      From the isolated tests below ( with attached example db )
      it looks like some of the storage in FMGo14 is recovered but not all, double what it should be.
      Also the overhead per container record appears to grow in a non linear manner on both FM OS X and FMGo14.
      Adding photos directly in FM on OS X appears to recover much of the storage that was not recovered in FMGo14.
      Unfortunately, only when another photo is added.  In my solutions all photos are added in FMGo14 so storage
      size grows quite rapidly  :  (
      The thumbnails are typically smaller than 1.1MB while the storage consumed for each image within
      the database appears to be average to 3.67 MB
      If this theory holds water how to I get the extra storage back as this is causing some real problems
      with sync times.
      calculation for container field
      // If the content of the container is an image shrink without distortion so max dimension is 1920
      // if it is not an image then return self. This would apply to audio, files and music
      // if image has a largest dimension that is less than 1920 then just use image do not attempt to enlarge image.
      If ( PatternCount  ( GetContainerAttribute ( Media;"filename" ) ; ".jpg" )  or
          PatternCount  ( GetContainerAttribute ( Media;"filename" ) ; ".png" )  or
          PatternCount  ( GetContainerAttribute ( Media;"filename" ) ; ".bmp" ) or
          PatternCount  ( GetContainerAttribute ( Media;"filename" ) ; ".gif" )    or
          PatternCount  ( GetContainerAttribute ( Media;"filename" ) ; ".tif" )
                  GetThumbnail (
                                          Self ;
                                          If ( GetWidth ( Self ) <  1920 ; GetWidth ( Self ) ; 1920 ) ;
                                          If ( GetHeight ( Self ) <  1920 ; GetHeight ( Self ) ; 1920 )
                                        ) ;
      Isolated Tests
      Created ContainerPhotoTest filemaker db with a single table and single field Media with
      GetThumbnail calculated result
      Move to iPhone 5s FMGo14 take photo
      ContainerPhotoTest  197 k with no photo
      ContainerPhotoTest  1.7MB with single photo
      Export Photo to desktop from Container
      Photo Size 467 KB
      But the database storage size has increased by 1.699 MB
      Add 8.6MB .jpg from the desktop in a second record
      ContainerPhotoTest  1.3 MB in size
      Drag photo to desktop from container
      Photo Size 623 KB
      ( 197 k + 467 k + 623 k ) = 1287 k 
      1,300 k - 1287 k = 13 k extra space used.
      What is happening here.
      So it looks like it works fine on OS X but perhaps not on iOS
      Try again with iPad Air 2 iOS
        • ContainerPhotoTest  1.3 MB in size
        • Take photo from FMGo14 Container
        • Take similar photo on iPad camera app
        • Photo Size 2.6 MB
        • ContainerPhotoTest 2.1MB in size
        • photo 800 k size increase
        • Photo size 467 k
        • Close and reopen FMGo14
        • ContainerPhotoTest 2.1MB in size
      So it seems that in iOS some space is recovered on the photo re-size but not all.
      Final Test on OS X
        • Create new record and.
        • ContainerPhotoTest 2.1MB in size
        • drop similar photo 2.2 MB into container from desktop
        • ContainerPhotoTest still 2.1MB in size, no increase in size...
        • Quit and re open database
        • ContainerPhotoTest still 2.1MB in size
        • drag new photo to desktop 467k
      ( 197 k + 467 k + 623 k + 467 k ) = 1754 k
      2,100 k - 1754 k =  345 k extra space used
      So it looks like something different is happening on OS X and FMGo
      I need to gather data including photos on FMGo and in practice as noted
      in the initial description of the production solution where no photos are added in OS X file size grows
      quite quickly.  
    • Container PDF PNG issue on Mac Preview
      By Beto Boton
      I'm having issues accessing a file that was added to Digital Docs tab of the Accounts Table.
      Both methods drag and drop and insert button were tested to add a PDF FILE and give the same issue.
      Manage Containers indicate on STORAGE the following [database location]/DB_Documents and on THUMBNAILS Generate and store thumb for images checked, Permanent storage checked.
      When I try to double click inside the container NOTHING HAPPEN and when I hit the button OPEN it shows the message on the image BUT NOTE that the text on the message is referring to a PNG file and not to a PDF
      Well using debugger and data watch the container has the correct name of the file "ASAKI prices list 2014.08.26.pdf" not PNG 
      If I open the folder DB_Documents/T01_ACCOUNTS/account_container
      the files(attached)  ASAKI prices list 2014.08.26.pdf AND ASAKI prices list 2014.08.26.png (generated- apparently the thumb nail with the internal storage)
      are present and when double clicked open without any problems in Preview.
      FINALLY this doesn't happen if the container has an Excel file or a word doc (non preview)
      Any help will substantially reduce my level of stress !

      Beto Boton
      Australia ASAKI prices list 2014.08.26.pdf