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:
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Developer server address |
| filePath | string | Yes | Path of the file resource to upload |
| name | string | Yes | Key corresponding to the file; on the server the developer can retrieve the binary content of the file via this key |
| header | Object | No | Header of the HTTP request; Referer cannot be set in the Header |
| formData | Object | No | Additional form data in the HTTP request |
| timeout | number | No | Timeout, in milliseconds |
| success | function | No | Callback function for a successful API call |
| fail | function | No | Callback function for a failed API call |
| complete | function | No | Callback function invoked when the API call ends |
Parameters of the success callback function
- Object res: returns the uploaded file information
res properties:
| Property | Type | Description |
|---|---|---|
| data | string | Data returned by the developer server |
| statusCode | number | HTTP 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
