uploadFile(params: Object)
Requires:
BaseKit≥2.0.1@ray-js/ray≥0.6.5
Platforms:
iOSAndroid
Description
Upload a local resource to the server. The client sends an HTTPS POST request with content-type multipart/form-data
Parameters
| Property | Type | Required | Default | Description | BaseKit Since |
|---|---|---|---|---|---|
url | string | Yes | - | Developer server URL | - |
filePath | string | Yes | - | Path of the file resource to upload (local path) | - |
name | string | Yes | - | The key for the file; the server can use this key to obtain the file’s binary content | - |
| No | - | HTTP request headers; Referer must not be set in the headers | - | ||
| No | - | Additional form data in the HTTP request | - | ||
timeout | number | No | - | Timeout in milliseconds | - |
method | "POST" | "PUT" | No | 'POST' | HTTP method for the upload request; defaults to POST | v3.23.0 |
complete | () => void | No | - | Completion callback (executed on both success and failure) | - |
success | (params: Object) => void | No | - | Callback on successful API call | - |
fail | (params: Object) => void | No | - | Failure callback | - |
success callback parameters
| Property | Type | Description | BaseKit Since |
|---|---|---|---|
data | string | Data returned by the developer server | v3.2.6 |
statusCode | number | HTTP status code returned by the developer server | v3.2.6 |
fail callback parameters
| Property | Type | Description |
|---|---|---|
errorMsg | string | Error message |
errorCode | string | number | Error code |
| Error extension |
Return Value
Type: UploadTask
UploadTask
| Property | Type | Description |
|---|---|---|
abort | function | Abort upload task |
onHeadersReceived | function | Listen for HTTP Response Header events. Fires earlier than the request completion event |
offHeadersReceived | function | Stop listening for HTTP Response Header events |
onProgressUpdate | function | Listen for upload progress change events |
offProgressUpdate | function | Stop listening for upload progress change events |
Valid Values
method
| Value | Description | BaseKit Since |
|---|---|---|
POST | HTTP POST request | v3.23.0 |
PUT | HTTP PUT request | v3.23.0 |