Livecode Wiki
Advertisement

Uploads data to an Internet server asynchronously via FTP.

Syntax:

libURLftpUpload value,uploadURL[,callbackMessage]

Examples:

libURLftpUpload field "Data","ftp://ftp.example.org/file.txt"
libURLftpUpload URL "binfile:data.jef",myURL,"uploadDone"
libURLftpUpload myData,"ftp://me:secret@example.net/file.txt"

Use the libURLftpUpload command to put a file on a server.

Parameters:

  • The value is any expression that evaluates to a string.
  • The uploadURL specifies the server and location to upload to, in the form of an FTP URL.
  • The callbackMessage is the name of a message to send after the URL is uploaded.

The libURLftpUpload command is non-blocking, so it does not stop the current handler while the upload is completed. The handler continues while the libURLftpUpload command uploads the URL in the background. You can monitor the upload by checking the URLStatus function periodically.

To upload a URL while blocking other operations, use the put command instead.

To upload a file, use the file URL type (for text files) or the binfile URL type (for binary files). Because referring to a file URL's contents loads the file into memory, if you are uploading a large file, make sure you have enough memory available. You can also use the libURLftpUploadFile command to upload a file.

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

Avoid using the wait command in a handler after executing the libURLftpUpload command. Since the libURLftpUpload command is non-blocking, it may still be running when your handler reaches the wait command. And since the libURLftpUpload command is part of the Internet library and is implemented in a handler, the wait command will stop the upload process if it is executed while the download is still going on. In particular, do not use constructions like the following, which will sit forever without uploading the file:

 libURLftpUpload field "Upload Data",myURL
 wait until the URLStatus of myURL is "uploaded" -- DON'T DO THIS

The URLStatus function returns the status of the uploaded file. If you no longer need to monitor the file's status, use the unload command to remove it from the URLStatus function's listing. The libURLftpUpload 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.

Note: When included in a standalone application, the Internet library is implemented as a hidden group and made available when the group receives its first openBackground message. During the first part of the application's startup process, before this message is sent, the libURLftpUpload command is not yet available. This may affect attempts to use this command in startup, preOpenStack, openStack, or preOpenCard handlers in the main stack. Once the application has finished starting up, the library is available and the libURLftpUpload command can be used in any handler.

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

Advertisement