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:
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
13.5
Statistic
FMM
Blog
Sets the list of FTP or SFTP commands to pass to the server prior to your FTP request.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
curl | The CURL session handle. | $curl |
Value... | The ftp commands. | "mkdir testfolder" |
Returns "OK" on success.
See also QUOTE option in CURL manual.
Delete file only with FTP:
MBS( "CURL.SetOptionQuote"; $curl; "DELE test.txt" )
Delete folder:
MBS( "CURL.SetOptionQuote"; $curl; "RMD testfolder" )
Create folder with FTP:
MBS( "CURL.SetOptionQuote"; $curl; "MKD testfolder" )
Rename file using two FTP commands:
MBS( "CURL.SetOptionQuote" ; $curl ; "RNFR foo.txt"; "RNTO bar.txt" )
Set file permissions for FTP:
MBS( "CURL.SetOptionQuote" ; $curl ; "SITE CHMOD 777 testfile")
Call with three parameters:
MBS( "CURL.SetOptionQuote"; handle; $value1; $value2; $value3 )
List all files:
MBS( "CURL.SetOptionQuote" ; $curl ; "NLST -all" )
Connect to FTP server and delete a file:
Set Variable [$curl; Value:MBS("CURL.New")]
#this is URL to ftp server
Set Variable [$r; Value:MBS("CURL.SetOptionURL"; $curl; "ftp://www.monkeybreadsoftware.com/")]
# set user name
Set Variable [$r; Value:MBS("CURL.SetOptionUserName"; $curl; "xxx")]
# set password
Set Variable [$r; Value:MBS("CURL.SetOptionPassword"; $curl; "xxx")]
# set delete command of file "test.jpg" in folder "images"
Set Variable [$r; Value:MBS("CURL.SetOptionQuote"; $curl; "DELE images/test.jpg")]
#run transfer
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
#get debug messages
Set Field [CURL Test::debug; MBS("CURL.GetDebugMessages"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Move file on SFTP in done folder with variables and quotes:
MBS("CURL.SetOptionQuote"; $curl;
// first delete
"rm " & "\"" & $Path & $folder & "Done/" & $$FileName & "\"";
// then move
"rename " & "\"" & $Path & $folder & "/" & $$FileName & "\"" & " " & "\"" & $Path & $folder & "Done/" & $$FileName & "\"")
Change file permissions via SFTP:
# set permissions to 777, so everyone can read/write/execute the file.
Set Variable [ $result ; Value: MBS( "CURL.SetOptionQuote"; $curl; "chmod 777 /Users/cs/Pictures/test.jpg" ) ]
Change file owner group via SFTP:
# change group to group 20
Set Variable [ $result ; Value: MBS( "CURL.SetOptionQuote"; $curl; "chgrp 20 /Users/cs/Pictures/test.jpg" ) ]
Change file owner via SFTP:
# change owner to user 501
Set Variable [ $result ; Value: MBS( "CURL.SetOptionQuote"; $curl; "chown 501 /Users/cs/Pictures/test.jpg" ) ]
Rename file after upload for SFTP:
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS( "CURL.SetOptionURL"; $curl; "sftp://test.com/folder/temp.jpg") ]
# credentials
Set Variable [ $result ; Value: MBS( "CURL.SetOptionPassword"; $curl; CURL Test::Password) ]
Set Variable [ $result ; Value: MBS( "CURL.SetOptionUserName"; $curl; CURL Test::Name) ]
Set Variable [ $result ; Value: MBS( "CURL.SetOptionSSHAuthTypes"; $curl; 2+8 ) ]
# data to upload from container field
Set Variable [ $result ; Value: MBS("CURL.SetOptionUpload"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetInputFile"; $curl; CURL Test::Image) ]
Set Variable [ $result ; Value: MBS("CURL.SetInputFile"; $curl; CURL Test::Image) ]
# Require TLS 1.2 for FTP over SSL:
Set Variable [ $result ; Value: MBS( "CURL.SetOptionUseSSL"; $curl; 3 ) ]
Set Variable [ $result ; Value: MBS( "CURL.SetOptionSSLVersion"; $curl; 6 ) ]
# download existing file, rename after upload
Set Variable [ $result ; Value: MBS( "CURL.SetOptionPostQuote"; $curl; "*rm image.jpg"; "rename temp.jpg image.jpg" ) ]
# see progress in debug messages
Set Variable [ $result ; Value: MBS( "CURL.SetDebugWithProgress"; $curl; 1 ) ]
# perform it
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
Created 18th August 2014, last changed 5th March 2023