Use the FileTransfer object to list and transfer files between the host system and the client.
The Host Access for the Cloud file transfer API abstracts the file path conventions used by different host file implementations. Follow URL or Linux file system path formats when formatting file paths used by the API. For example, /root/directory/file. It is important to observe any rules specific to host systems, such as allowable characters or name lengths.
NOTE:Browsers place significant security restrictions around the ability of Javascript to interact with client file systems.
Table 5-23 FileTransfer
Method |
|
---|---|
getHostFileListing(remotePath) |
Request a listing of host files. If remotePath is omitted, a file listing for the current remote working directory is shown. Parameters {String} (optional) If specified will get file listing for specified remote path. If not specified, will get file listing for current remote working directory. Returns {Promise} Resolves to an array of HostFile objects contained at remoteName. Rejected if the remote path can not be read. |
sendFile(localFile, remoteName) |
Sends specified file to the host. Parameters {File} Javascript file object pointing to local file to send. {String} Fully-qualified remote file name as allowed by remote system (Unix, Windows, MVS, VAX). Returns {Promise} fulfilled with a HostFile object representing the sent file on success. Rejected if an error occurred sending the file. |
getDownloadURL(remoteName) |
Constructs a link to download a file from a host system. Parameters {String} Fully-qualified remote file name as allowed by remote system (Unix, Windows, MVS, VAX). Returns {URL} that can be used to retrieve the file from the Host Access for the Cloud session server. |
setTransferOptions(options) |
Set transfer options for current FileTransfer session. The transfer options are applied to all future transfers until the session is either exited or overridden by another call to setTransferOptions. Parameters {JSON} see FileTransferOptions for allowed names and values. Returns {Promise} fulfilled when the call completes. Rejected if an error occurred setting the options. |
cancel() |
Cancels the current transfer in progress. Returns {Promise} fulfilled when the call completes. Rejected if an error occurred canceling the transfer. |