Skip to content

sud.uploadFile ​

JS
    sud.uploadFile (Object object)

Uploads a local resource to the server.

The client issues an HTTP(S) POST request with content-type set to multipart/form-data.

Parameters

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

object properties:

PropertyTypeRequiredDescription
urlstringYesDeveloper server address
filePathstringYesPath of the file resource to upload
namestringYesKey corresponding to the file; on the server the developer can retrieve the binary content of the file via this key
headerObjectNoHeader of the HTTP request; Referer cannot be set in the Header
formDataObjectNoAdditional form data in the HTTP request
timeoutnumberNoTimeout, in milliseconds
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 uploaded file information

res properties:

PropertyTypeDescription
datastringData returned by the developer server
statusCodenumberHTTP status code returned by the server

Return Value

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