Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
CURL.OpenInputFile
Opens file for reading data needed for upload, email sending or HTTP Post.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.6 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
curl | The CURL session handle. | $curl | |
Path | Native file path. | "C:\Documents\Test.Txt" | |
Offset | Available in MBS FileMaker Plugin 8.4 or newer. Offset where to start reading relative to file start. |
1024*1024 | Optional |
Length | Available in MBS FileMaker Plugin 8.4 or newer. Size of data to read from file. |
1024*1024*10 | Optional |
Result
Returns "OK" on success or error message.
Description
Opens file for reading data needed for upload, email sending or HTTP Post.If you set input file, the data from CURL.SetInput* functions is ignored.
Do not call this method while a transfer is running.
If you have data in container, please check CURL.SetInputFile.
You may need to use CURL.SetOptionUpload to make it an upload for FTP/SFTP.
If you specify offset or length, we only read that part of the file in memory.
Otherwise we stream from the file on request.
If you get an upload with 0 bytes length, it is quite likely, that this function couldn't open the file due to an invalid path or insufficient permissions.
This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.
Examples
Set input from file on disk:
Set Variable [ $result ; Value: MBS( "CURL.OpenInputFile"; $curl; "/Users/cs/Desktop/test.zip" ) ]
Upload file via FTP:
Set Variable [$curl; Value:MBS("CURL.New")]
# FTP URL with destination file name:
Set Variable [$result; Value: MBS("CURL.SetOptionURL" ; $curl ; "ftp://12.34.56.78/AZ1677ZZ.jpg")]
Set Variable [$result; Value: MBS("CURL.SetOptionUpload" ; $curl ; 1)]
Set Variable [$result; Value: MBS("CURL.SetOptionPassword" ; $curl ; "xxx" )]
Set Variable [$result; Value: MBS("CURL.SetOptionUserName" ; $curl ; "yyy" )]
# Pick file from desktop:
Set Variable [$Desktop; Value: MBS("Folders.UserDesktop")]
Set Variable [$Path; Value: MBS("Path.AddPathComponent"; $desktop; "AZ1677ZZ.jpg")]
Set Variable [$result; Value: MBS( "CURL.OpenInputFile" ; $curl ;$path )]
# Pick file from container:
// Set Variable [$result; Value: MBS( "CURL.SetInputFile" ; $curl ; Test::ImageFileContainer )]
# Upload file
Set Field [Test::PerformResult; MBS( "CURL.Perform" ; $curl )]
Set Field [Test::DebugMessages; MBS( "CURL.GetDebugMessages" ; $curl)]
Set Variable [$result; Value:MBS( "CURL.Release" ; $curl )]
See also
- CURL.CloseInputFile
- CURL.SetOptionPostFields
- CURL.SetOptionSSHPrivateKeyfile
- CURL.SetOptionSSHPublicKeyfile
- CURL.SetOptionUpload
- CURL.SetOptionUserName
- Folders.UserDesktop
- Hash.Digest
- Path.AddPathComponent
- Path.FileMakerPathToNativePath
Release notes
- Version 12.1
- Fixed CURL.OpenInputFile to stream files over 1 GB again.
- Version 8.4
- Added new parameters for CURL.OpenInputFile to load files in chunks.
Example Databases
- CURL/Amazon S3/Amazon S3 Upload File
- CURL/CURL Custom Function
- CURL/FTP/CURL FTP Upload File
- CURL/FTP/CURL FTP Upload from file with Progress
- CURL/SFTP/CURL sFTP Upload File
Blog Entries
- CURL Custom Function
- MBS FileMaker Plugin, version 12.1pr7
- Translating Insert from URL options for CURL to MBS Plugin calls
- Comparing Base Elements Plugin to MBS FileMaker Plugin
- Tip of the day: FTP File Upload
- MBS Filemaker Plugin, version 4.2pr1
- MBS Filemaker Plugin, version 3.3pr1
- MBS Filemaker Plugin, version 2.6pr4
This function checks for a license.
Created 18th August 2014, last changed 14th July 2023