Skip to content

sud.downloadFile ​

JS
    sud.downloadFile (Object object)

Downloads a file resource to local storage.

The client directly issues an HTTP GET request and returns the local file path of the file. The maximum file size allowed for a single download is 50MB.

Parameters

  • Object object: input parameters, described in the table below

object properties:

PropertyTypeRequiredDescription
urlstringYesURL of the resource to download
headerObjectNoHeader of the HTTP request; Referer cannot be set in the Header
timeoutnumberNoTimeout, in milliseconds
filePathstringNoPath where the downloaded file is stored
successfunctionNoCallback function for a successful API call
failfunctionNoCallback function for a failed API call
completefunctionNoCallback function invoked when the API call ends

Parameters of the success callback function

  • Object res: returns the download information

res properties:

PropertyTypeDescription
tempFilePathstringTemporary file path. Returned when filePath is not passed to specify the storage path; the downloaded file is stored in the temporary directory
filePathstringUser file path. Returned when filePath is passed; identical to the passed filePath
statusCodenumberHTTP status code returned by the server

Return Value

  • DownloadTask: returns an object that can listen for download progress change events and cancel the download task