CURL.CloseOutputFile
--------------------

Closes the data output file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.6](newinversion26.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.CloseOutputFile"; curl ) 

**MBS**( **"CURL.CloseOutputFile";** /\* Closes the data output file. \*/  
**$curl**) /\* The CURL session handle. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| curl | The CURL session handle. | $curl |

### Result

Returns "OK" on success or error message.

### Description

Closes the data output file.  
To create file for data use [CURL.CreateOutputFile](CURLCreateOutputFile.md) function.  
The plugin closes files automatically when you call [CURL.Release](CURLRelease.md).  
Do not call this method while a transfer is running.  
In case close operation itself fails, the result is a number with the native file system error code.  
### Examples

Download URL to temp file:

 Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\#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](PathLastPathComponent.md)"; $URL )\]  
\#now make temp file path   
Set Variable \[$path ; Value:MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.SystemTemporary](FoldersSystemTemporary.md)" ); $name )\]  
\#set URL to download   
Set Variable \[$r ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; $url )\]  
\#open destination file   
Set Variable \[$r ; Value:MBS ("[CURL.CreateOutputFile](CURLCreateOutputFile.md)"; $curl ; $path )\]  
\#run transfer   
Set Field \[CURL Test::Result ; MBS ("[CURL.Perform](CURLPerform.md)"; $curl )\]  
\#close destination file   
Set Variable \[$r ; Value:MBS ("CURL.CloseOutputFile"; $curl )\]  
\#get debug messages   
Set Field \[CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Close output file:

 MBS ("CURL.CloseOutputFile"; $curl )  
### See also

- [CURL.CloseDebugFile](CURLCloseDebugFile.md)
- [CURL.CreateOutputFile](CURLCreateOutputFile.md)
- [CURL.GetDebugMessages](CURLGetDebugMessages.md)
- [CURL.New](CURLNew.md)
- [CURL.Perform](CURLPerform.md)
- [CURL.Release](CURLRelease.md)
- [CURL.SetOptionURL](CURLSetOptionURL.md)
- [Folders.System](FoldersSystem.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Path.LastPathComponent](PathLastPathComponent.md)

### Release notes

- **Version 9.4**
    - Fixed a bug in [CURL.CloseDebugFile](http://www.mbsplugins.eu/CURLCloseDebugFile.shtml), [CURL.CloseHeaderFile](http://www.mbsplugins.eu/CURLCloseHeaderFile.shtml), [CURL.CloseInputFile](http://www.mbsplugins.eu/CURLCloseInputFile.shtml) and [CURL.CloseOutputFile](http://www.mbsplugins.eu/CURLCloseOutputFile.shtml) to avoid.

### Blog Entries

- [MBS FileMaker Plugin, version 9.4pr1](https://www.mbsplugins.de/archive/2019-08-08/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.6pr4](https://www.mbsplugins.de/archive/2012-02-17/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 3th January 2023

  
[CURL.CloseInputFile](CURLCloseInputFile.md) - [CURL.CreateDebugOutputFile](CURLCreateDebugOutputFile.md)

[HTML Version](CURLCloseOutputFile.shtml)