« MBS FileMaker Plugin … | Home | Christmas surprise pa… »

Translating Insert from URL options for CURL to MBS Plugin calls

You may have a few options for an Insert from URL script step and you may want to convert them to a script using MBS FileMaker Plugin.

e.g.
" --user myusername:mypassword --upload-file $file --header \"Content-type: image/png\""

Which translates to a script like this:

Set Variable [$curl; Value:MBS("CURL.New")]
# set options
Set Variable [$r; Value: MBS( "CURL.SetOptionURL"; $curl; $URL)]
Set Variable [$r; Value: MBS( "CURL.SetOptionUpload"; $curl; 1)]
Set Variable [$r; Value: MBS( "CURL.SetOptionUserName"; $curl; "myusername" )]
Set Variable [$r; Value: MBS( "CURL.SetOptionPassword"; $curl; "mypassword" )]
Set Variable [$r; Value: MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-type: image/png" )]
Set Variable [$r; Value: MBS( "CURL.SetInputFile"; $curl; $file )]
# run transfer
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl) ]
Set Field [CURL Test::DebugMessages; MBS("CURL.GetDebugAsText"; $curl) ]
Set Variable [$result; Value: MBS("CURL.Release"; $curl) ]


As you see we set a few options like the URL (with filename for uploaded file), the user name and password for the login and a HTTP header for the content type. If you'd use ftp:// URL for a ftp upload, you won't need the HTTP headers and the option would be ignored if you set it. But if you do a HTTP upload, it's oft course good to pass the mime type to the receiving script on the web server.

Let's take a look on all the options:

--anyauth

Use any HTTP authentication method available. This should be default and you can configure it with CURL.SetOptionHTTPAuth function.

--basic

Use basic authentication. Call CURL.SetOptionHTTPAuth with 1 as flag value.

--cert or -E

You can specify an SSL certificate with CURL.SetOptionSSLCert function. This function takes a native file path, while the newer CURL.SetOptionSSLCertBlob function takes a container value or text representation with the certificate. Using CURL.SetOptionSSLCertType you specify the type of key file. Default is PEM format, but it could also be DER or P12 for a PKCS#12 encoded file. See also CURL.SetOptionKeyPassword to pass a password for encrypted keys.

--cert-type

Pass the certificate type via CURL.SetOptionSSLCertType function.

--ciphers

Use CURL.SetOptionSSLCipherList function to pass a cipher list.

--connect-timeout

Call CURL.SetOptionConnectionTimeout function with the timeout value to use in seconds.

--continue-at or -C

For resuming an upload or download, please use CURL.SetOptionResumeFrom to pass the new offset. This may allow you for example to resume a FTP upload.

--cookie or -b

Use CURL.SetOptionCookie to specify a cookie for a HTTP transfer.

--cookie-jar or -c

Use CURL.SetOptionCookieJar to specify the file path to the cookie file.
Pass empty path to use in memory file (not persistent).

--crlf

Use CURL.SetOptionCRLF function to specify the 1 to convert line endings to Windows format.

--data or -d

Pass data to upload via CURL.SetInputText or similar functions.
If you do HTTP POST operation, please use CURL.SetOptionPostFields instead.

--data-ascii and --data-binary and --data-raw

Use CURL.SetOptionTransferText function to specify whether FTP transfer is ASCII or binary.

--data-urlencode

You can URL encode data via functions in FileMaker or our plugin if needed and pass to the functions for input.

--digest

Use CURL.SetOptionHTTPAuth function to specify 2 for the digest authentication option.

--disable-eprt

Use CURL.SetOptionFTPUseEPRT function to enable or disable the use of EPRT in the FTP transfer.
For FTP transfers we usually offer this as option in case you have a very old server.

--disable-epsv

Use CURL.SetOptionFTPUseEPSV function to enable or disable the use of EPRT in the FTP transfer.
For FTP transfers we usually offer this as option in case you have a very old server.

--dump-header or -D

Please use CURL.GetHeaderAsText function to query header text after transfer.
If you prefer, try the CURL.GetHeaderAsJSON function to get headers as JSON block.

--expect100-timeout

Use CURL.SetOptionExpect100TimeoutMS function to specify the timeout in milliseconds.
While FileMaker uses seconds, we have milliseconds.

--fail or -f

Check result from CURL.Perform whether it returns OK.
For HTTP or FTP, you may go with CURL.GetResponseCode to check error code and see whether transfer is successful.
e.g. for HTTP transfer may succeed on the lower level, but report an error on the application level, e.g. 404 for file not found.

--FM-return-container-variable

Use CURL.GetResultAsContainer function after transfer to get result as container.
We look in headers to determine type. Otherwise use CURL.GetResultAsJPEG, CURL.GetResultAsPDF, CURL.GetResultAsPNG, CURL.GetResultAsText or other functions to get result.

--FM-text-encoding

When setting input text or post fields, you can tell the plugin what encoding to use.

--form or -F or --form-string

Use MBS FileMaker Plugin functions like CURL.FormAddKeyValue to add form entries for a form data upload. Use CURL.FormAddKeyContainer to pass container, CURL.FormAddKeyText for a bigger text block or CURL.FormAddKeyFile for a file on disk.

--ftp-alternative-to-user

Pass your user text to CURL.SetOptionFTPAlternativeToUser function for FTP transfer if needed.

--ftp-create-dirs

Tell FTP functions to create missing directories with CURL.SetOptionFTPCreateMissingDirs function. Otherwise you can use pre-quote to create folders if needed.

--ftp-method

Use CURL.SetOptionFTPFileMethod function to specify

--ftp-pasv

Use CURL.SetOptionFTPUseEPSV function to disable EPSV and use PASV instead.

--ftp-port or -P

Use CURL.SetOptionFTPPort to specify the range of ports to be used for PORT command in FTP transfer.

--ftp-pret

For FTP transfers, you can use CURL.SetOptionFTPUsePret function

--ftp-skip-pasv-ip

Use CURL.SetOptionFTPSkipPasvIP function to skip IP for PASV command in a FTP transfer.

--ftp-ssl-ccc and --ftp-ssl-ccc-mode

Use CURL.SetOptionFTPSSLCCC function to set Clear Command Channel flag. Pass the flag 1 for passive, 2 for active or 0 for non CCC.

--ftp-ssl-control

Pass 3 to CURL.SetOptionUseSSL in order to enable SSL for the transfer in both data and control part.

--head or -I

Pass 1 to CURL.SetOptionHeader function to only query header and no actual data.

--header or -H

Pass parameters to CURL.SetOptionHTTPHeader function or list of header entries.

--ignore-content-length

Pass 1 to CURL.SetOptionIgnoreContentLength to ignore content length and just accept all data receiving until the server drops connection.

--interface

Pass interface name to CURL.SetOptionInterface function to pick which Wifi or Ethernet.

--ipv4 or -4 and --ipv6 or -6

Use CURL.SetOptionIPResolve function to pick whether you like to use IPv4 or IPv6.

--junk-session-cookies or -j

You can use CURL.SetOptionCookieJar with "" as path to get a non-persistent in-memory cookie storage. Later you can use CURL.SetOptionCookieSession to start a new cookie session.

--keepalive-time

Pass keep alive time value to CURL.SetOptionTCPKeepAlive function.

--key-type

The default key type is PEM, but you can pass DER, P12 or PEM to CURL.SetOptionSSLKeyType function to select the key type to use.

--key

Pass a SSL key file path to CURL.SetOptionSSLKey function. If your key is stored in a container or as text in a field, you can pass it to CURL.SetOptionSSLKeyBlob function.
Valid key formats include DER, PEM and P12. If a password is needed to decrypt the key, you can pass it to CURL.SetOptionKeyPassword function.

--limit-rate

Use CURL.SetOptionMaxRecvSpeed and CURL.SetOptionMaxSendSpeed function to specify the speed limit in bytes per second.

--list-only or -l

Pass 1 for CURL.SetOptionDirListOnly function to only get a file listing for ftp/sftp connections.

--local-port

Pass the local port number to use with CURL.SetOptionFTPPort function when specifying the IP address to use.

--location or -L

Pass 1 to CURL.SetOptionFollowLocation function to let the HTTP connection follow a redirect.

--location-trusted

Not used in MBS FileMaker Plugin.

--mail-auth

Pass authentication address to CURL.SetOptionMailAuth function.
This is set automatically by SendMail.PrepareCURL function when you prepare sending an email with our plugin.

--mail-from

Pass address of from email address to CURL.SetOptionMailFrom function.
This is set automatically by SendMail.PrepareCURL function when you prepare sending an email with our plugin.

--mail-rcpt

Pass the recipient address list to CURL.SetOptionMailRecipients function.
This is set automatically by SendMail.PrepareCURL function when you prepare sending an email with our plugin.

--max-filesize

Use CURL.SetOptionMaxFileSize option to specify maximum file size in bytes.

--max-time or -m

Specify the maximum time for the transfer with CURL.SetOptionTimeOut function.

--no-compressed

Use CURL.SetOptionAcceptEncoding to allow accepting compressed response.
And use CURL.SetOptionTransferEncoding function to have CURL decompress the answer if needed.

--no-keepalive

Use CURL.SetOptionTCPKeepAlive function to enable/disable keep alive status.
Keep alive messages are send (if requested) to avoid a timeout in the transfer while the server prepares the answer.

--noproxy

Use CURL.SetOptionNoProxy function to pass the list of hosts where no proxy is needed.

--output or -o

Pass a filename parameter to CURL.GetResultAsContainer function to overwrite the file name.

--pass

You can specify a password for a private key with CURL.SetOptionKeyPassword function.

--path-as-is

Pass 1 to CURL.SetOptionPathAsIs function to specify that path is not corrected for URLs.

--post301, --post302 or --post303

Use CURL.SetOptionPostRedir function to specify the behavior for redirects for POST operation.

--proxy or -x

Pass proxy specification to CURL.SetOptionProxy function.

--proxy-anyauth or --proxy-basic or --proxy-digest

Pass the flags you want to the CURL.SetOptionProxyAuth function.

--proxy-header

You can use CURL.SetOptionProxyHeader function to configure the headers to pass to proxy server.

--proxy-user or -U

Pass user name to CURL.SetOptionProxyUsername function. The password is passed via CURL.SetOptionProxyPassword function.

--proxy1.0

Use CURL.SetOptionProxyType to specify the proxy type.

--proxytunnel or -p

Use CURL.SetOptionHTTPProxyTunnel to specify the proxy options for tunneling.

--quote or -Q

Pass additional commands to run before transfer with CURL.SetOptionPreQuote function. If you like to do custom commands with CURL.SetOptionQuote or CURL.SetOptionPostQuote for later commands.

--range or -r

You can pass the range as parameter to CURL.SetOptionRange function.
This allows to download only a given range of a file in a HTTP download.

--raw

Pass 0 to CURL.SetOptionAcceptEncoding and CURL.SetOptionTransferEncoding to disable handling of compressed transfers.

--referer or -e

Pass your referrer URL to the CURL.SetOptionReferer function.
In a redirect, a referrer may be used automatically.

--request or -X

Pass your custom request to CURL.SetOptionCustomRequest function.

--resolve

Pass the resolver to use with CURL.SetOptionResolve function.

--show-error or -S

The plugin returns you error with CURL.Perform function or CURL.ErrorCode for asynchronous requests.

--socks4 or --socks4a or --socks5 or --socks5-hostname

Use CURL.SetOptionProxyType to specify version of socks server.
And pass the proxy server specification to CURL.SetOptionProxy function.

--speed-limit or -Y

Use CURL.SetOptionLowSpeedLimit to specify a limit in bytes for detecting low speed transfers and cancel.

--speed-time or -y

Pass time for CURL.SetOptionLowSpeedTime function for detecting low speed transfers and cancel.

--ssl or --ftp-ssl or --ssl-reqd

Enable SSL with CURL.SetOptionUseSSL function or with a protocol containing an S like HTTPS, FTPS, SFTP, IMAPS or POP3S.

--time-cond or -z

Pass the time condition to CURL.SetOptionTimeCondition function.

Only supports specifying a cURL-style date expression.

--tr-encoding

Pass text encoding for debug messages to CURL.GetDebugAsText function.

--trace

Our plugin always writes a trace log, which can be queried with CURL.GetDebugAsText function.

--trace-ascii

Not needed with MBS FileMaker Plugin.

--trace-time

Pass 1 to CURL.SetDebugWithTime in order to enable debug messages to contain timestamps.

--upload-file or -T

Specify file to upload with one of the input functions: CURL.SetInputFile for container, CURL.SetInputGIF, CURL.SetInputJPEG, CURL.SetInputPDF, CURL.SetInputPNG or CURL.SetInputText for text. Use CURL.OpenInputFile to stream a file on disk.

--use-ascii or -B

Use CURL.SetOptionTransferText function to specify whether transfer is handled as text (Ascii) or binary.

--user or -u

You can pass username to CURL.SetOptionUserName function and password to CURL.SetOptionPassword function.

--user-agent or -A

Custom user agents can be specified with CURL.SetOptionUserAgent function.

--version or -V

Queries CURL library version with CURL.Version function. You can also query IDN library version with CURL.LibIDNVersion function, SSH library version with CURL.LibSSHVersion or SSL library version with CURL.LibSSLVersion function.

Please don't hesitate to contact us if you have questions.
14 12 20 - 08:38