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
Returns the result of the transaction as container value with auto detection of type.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 5.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
curl | The CURL session handle. | $curl | |
Filename | The desired file name | test.jpg | Optional |
PluginDetect | If 1 the plugin will do the file type detection. If not provided or 0 and the FileMaker version is 13.0 or newer, the FileMaker engine will decide on the type. | Optional |
Returns OK or error.
Load JPEG from URL to container:
# start new transfer
Set Variable [$curl; Value:MBS("CURL.New")]
# set URL
Set Variable [$r; Value:MBS("CURL.SetOptionURL"; $curl; "https://monkeybreadsoftware.com/filemaker/images/devcon2013.jpg")]
# run transfer
Set Variable [$ErrorCode; Value:MBS("CURL.Perform"; $curl)]
# get result as JPG and store in field:
Set Variable [$Result; Value:MBS( "CURL.GetResultAsContainer"; $curl)]
Set Field [test::MyContainerField; $Result]
# get debug messages:
Set Variable [$DebugMessages; Value:MBS( "CURL.GetDebugAsText"; $curl)]
# cleanup
Set Variable [$r; Value:MBS("CURL.Release"; $curl)]
Download picture and scale it down:
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; MIX::URL) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionFollowLocation"; $curl; 1) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionMaxRedirs"; $curl; 3) ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
Set Variable [ $debug ; Value: MBS( "CURL.GetDebugAsText"; $curl) ]
If [ $result = "OK" ]
Set Variable [ $Image ; Value: MBS( "CURL.GetResultAsContainer"; $curl) ]
Set Variable [ $ImageRef ; Value: MBS("GMImage.NewFromContainer"; $image) ]
If [ MBS("IsError") = 0 ]
Set Variable [ $r ; Value: MBS("GMImage.Scale";$ImageRef; "256x256>") ]
Set Variable [ $ScaledImage ; Value: MBS("GMImage.WriteToJPEGContainer"; $ImageRef) ]
If [ MBS("IsError") = 0 ]
Set Field [ MIX::Image ; $ScaledImage ]
End If
Set Variable [ $r ; Value: MBS("GMImage.Release";$ImageRef) ]
End If
End If
Set Variable [ $r ; Value: MBS("CURL.Release"; $curl) ]
Get file name for container from header:
Set Variable [ $name ; Value: "" ]
Set Variable [ $headers ; Value: MBS( "CURL.GetHeaderAsText"; $curl; "UTF-8") ]
Set Variable [ $headers ; Value: MBS( "List.MatchesPrefix"; $headers; "Content-Disposition: attachment; filename=") ]
If [ Length($headers) > 0 ]
Set Variable [ $name ; Value: Middle ( $headers ; 43 ; Length($headers) ) ]
End If
Set Field [ CURL Test::File ; MBS("CURL.GetResultAsContainer"; $curl; $name) ]
Created 15th June 2015, last changed 19th April 2020
CURL.GetResponseCode - CURL.GetResultAsData
Feedback: Report problem or ask question.