Livecode Wiki
mNo edit summary
Tags: Visual edit apiedit
(ASCII)
Tag: sourceedit
 
Line 19: Line 19:
 
The '''libURLDownloadToFile''' command transfers the data directly from the file to the server. Unlike simply using the [[put]] command to put the contents of a URL into a file, using the libURLDownloadToFile command does not load all the data into memory at once, so this command is '''a better choice for large files'''.
 
The '''libURLDownloadToFile''' command transfers the data directly from the file to the server. Unlike simply using the [[put]] command to put the contents of a URL into a file, using the libURLDownloadToFile command does not load all the data into memory at once, so this command is '''a better choice for large files'''.
   
The libURLDownloadToFile command transfers the file in '''binary mode'''.
+
The libURLDownloadToFile default command transfers the file in '''binary mode'''. You can set in ASCII mode using '''TYPE=A''' option:
  +
libURLDownloadToFile "ftp://" & lServer & lServerPath & lServerFile & ";TYPE=A", lLocalFile,"downloadDone"
  +
  +
   
 
The ''callbackMessage'' is sent to the object whose script contains the '''libURLDownloadToFile''' command, after the download is complete, so you can handle the ''callbackMessage'' to perform any tasks you want to delay until the file has been downloaded. Two parameters are sent with the message: the ''URL'' and the ''URLStatus'' of the file.
 
The ''callbackMessage'' is sent to the object whose script contains the '''libURLDownloadToFile''' command, after the download is complete, so you can handle the ''callbackMessage'' to perform any tasks you want to delay until the file has been downloaded. Two parameters are sent with the message: the ''URL'' and the ''URLStatus'' of the file.

Latest revision as of 14:21, 29 December 2016

Downloads a file from an Internet server asynchronously via FTP, HTTP or HTTPS

Syntax:

libURLDownloadToFile downloadURL,filePath[,callbackMessage]

Examples:

libURLDownloadToFile "ftp://example.org/new_beta",it
libURLDownloadToFile myFile,newPath,"downloadComplete"

Use the libURLDownloadToFile command to download a file from an FTP Server or Web Server.

The downloadURL specifies the server and file to download, in the form of an FTP, HTTP or HTTPS url.

The filePath specifies the name and location to save the downloaded file in. If you specify a name but not a location, LiveCode assumes the file is in the defaultFolder.

The callbackMessage is the name of a message to send after the download is finished.

The libURLDownloadToFile command transfers the data directly from the file to the server. Unlike simply using the put command to put the contents of a URL into a file, using the libURLDownloadToFile command does not load all the data into memory at once, so this command is a better choice for large files.

The libURLDownloadToFile default command transfers the file in binary mode. You can set in ASCII mode using TYPE=A option:

libURLDownloadToFile "ftp://" & lServer & lServerPath & lServerFile & ";TYPE=A", lLocalFile,"downloadDone"


The callbackMessage is sent to the object whose script contains the libURLDownloadToFile command, after the download is complete, so you can handle the callbackMessage to perform any tasks you want to delay until the file has been downloaded. Two parameters are sent with the message: the URL and the URLStatus of the file.

On Mac OS and OS X systems, the new file's creator signature and file type is set to the value specified in the fileType property.

The libURLDownloadToFile command is part of the Internet library. To ensure that the command works in a standalone application, you must include this custom library when you create your standalone. In the Inclusions section of the Standalone Application Settings window, make sure "Internet Library" is selected in the list of script libraries.

See: Internet library

On iOS and Android libURLDownloadToFile is blocking until the download is complete. Completion of the download is notified by the urlProgress message, where you can test if the downloaded status is set.

See Also: libURLftpUploadFile Command, libURLSetFTPStopTime Command, libURLSetStatusCallback Command, load Command, put Command, unload Command, URLStatus Function, libURLFollowHttpRedirects Command