Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Creates output file for downloading data.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.6 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
curl | The CURL session handle. | $curl |
Path | Native file path. | C:\Documents\Test.Txt |
Returns "OK" on success or error message.
Write data to a file on Mac in temp folder:
MBS( "CURL.CreateOutputFile"; $curl; "/tmp/download.dat" )
Write data only to file on Windows:
MBS( "CURL.SetOptionFileOnlyMode"; $curl; 1 )
MBS( "CURL.CreateOutputFile"; $curl; "c:\download.dat" )
Download URL to temp file:
Set Variable [$curl; Value:MBS("CURL.New")]
#this is URL to download
Set Variable [$url; Value:"https://www.monkeybreadsoftware.com/filemaker/test.txt"]
#get file name from URL
Set Variable [$name; Value:MBS( "Path.LastPathComponent"; $URL )]
#now make temp file path
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; MBS( "Folders.SystemTemporary" ); $name )]
#set URL to download
Set Variable [$r; Value:MBS("CURL.SetOptionURL"; $curl; "https://www.monkeybreadsoftware.com/filemaker/test.txt")]
#open destination file
Set Variable [$r; Value:MBS("CURL.CreateOutputFile"; $curl; $path)]
#run transfer
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
#close destination file
Set Variable [$r; Value:MBS("CURL.CloseOutputFile"; $curl)]
#get debug messages
Set Field [CURL Test::debug; MBS("CURL.GetDebugAsText"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Download file via SFTP to file on disk:
Set Variable [$curl; Value:MBS("CURL.New") ]
# set download URL, e.g. sftp://monkeybreadsoftware.net/test.jpg
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; SFTP Download::URL )]
# build file path on disk and open output file
Set Variable [$name; Value:GetValue(SFTP Download::FileName; 1)]
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; SFTP Download::FolderPath; $name )]
Set Variable [$r; Value:MBS("CURL.CreateOutputFile"; $curl; $path)]
# login only via password
Set Variable [$result; Value:MBS( "CURL.SetOptionSSHAuthTypes"; $curl; 2+8 )]
# set credentials
Set Variable [$result; Value:MBS("CURL.SetOptionUserName"; $curl; SFTP Download::UserName )]
Set Variable [$result; Value:MBS("CURL.SetOptionPassword"; $curl; SFTP Download::Password )]
# run transfer
Set Field [SFTP Download::ErrorCode; MBS("CURL.Perform"; $curl)]
# check debug log for errors
Set Field [SFTP Download::Debug; MBS("CURL.GetDebugAsText"; $curl)]
# free CURL session
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Batch download a lot of files via FTP/SFTP:
# URL field contains ftp or sftp URL with / on end.
# FileList field contains list of files to load
# OutputPath field contains folder path on disk
#
Set Variable [$i; Value:1]
Set Variable [$max; Value:ValueCount ( SFTP Download::FileList )]
#
Set Variable [$curl; Value:MBS("CURL.New")]
#
# login only via password
Set Variable [$result; Value:MBS( "CURL.SetOptionSSHAuthTypes"; $curl; 2+8 )]
#
# set credentials
Set Variable [$result; Value:MBS("CURL.SetOptionUserName"; $curl; SFTP Download::UserName )]
Set Variable [$result; Value:MBS("CURL.SetOptionPassword"; $curl; SFTP Download::Password )]
#
# start loop over file lists
Loop
#
Set Variable [$name; Value:GetValue ( SFTP Download::FileList ; $i )]
#
# build file path on disk and open output file
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; SFTP Download::OutputPath; $name )]
Set Variable [$r; Value:MBS("CURL.CreateOutputFile"; $curl; $path)]
#
# set URL with file name
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; SFTP Download::URL & $name )]
#
# run transfer
Set Field [SFTP Download::ERGEBNIS; MBS("CURL.Perform"; $curl)]
#
# query debug log
Set Field [SFTP Download::DEBUG; MBS("CURL.GetDebugAsText"; $curl)]
#
Set Variable [$i; Value:$i +1]
Exit Loop If [$max = $i]
#
End Loop
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Created 18th August 2014, last changed 19th April 2020
CURL.CreateHeaderOutputFile - CURL.ErrorCode
Feedback: Report problem or ask question.