bn.uploadFile
▸ uploadFile(options
): UploadTask
description
Uploads local resources to the server. The client initiates a HTTPS POST Request, wherein content-type for multipart/form-data.
example
Parameters
Name | Type |
---|---|
options | UploadFileOption |
Returns
UploadTask
UploadTask
#
Interface: UploadFileOptionName | Type | Description |
---|---|---|
url | string | Developer server address |
filePath | string | Path to upload file resource (local path) |
name | string | The key corresponding to the file, the developer can get the binary content of the file through this key on the server side |
header | Headers | Header of HTTP request, Referer cannot be set in Header |
formData | Record <string , string > | Other additional form data in the HTTP request |
timeout | number | Timeout time.default 2000 |
method | "POST" | "PUT" | remark sdk > 4.9.0; Method used when upload file, support 'POST' or 'PUT'. |
complete | UploadFileCompleteCallback | The callback function for the end of the interface call (it will be executed when the call succeeds or fails) |
fail | UploadFileFailCallback | The callback function of interface call failure |
success | UploadFileSuccessCallback | Callback function for successful interface call |
#
Interface: UploadTaskName | Type | Description |
---|---|---|
abort | (): void | Interrupt upload task |
offHeadersReceived | (callback? ): void | Cancel listening to the HTTP Response Header event |
offProgressUpdate | (callback? ): void | Cancel listening to upload progress change events |
onHeadersReceived | (callback ): void | Listen to the HTTP Response Header event. Will be earlier than the request completion event |
onProgressUpdate | (callback ): void | Listen to upload progress change events |
#
abort▸ abort(): void
Interrupt upload task
Returns
void
#
offHeadersReceived▸ offHeadersReceived(callback?
): void
Cancel listening to the HTTP Response Header event
Parameters
Name | Type |
---|---|
callback? | OffHeadersReceivedCallback |
Returns
void
#
offProgressUpdate▸ offProgressUpdate(callback?
): void
Cancel listening to upload progress change events
Parameters
Name | Type |
---|---|
callback? | UploadTaskOffProgressUpdateCallback |
Returns
void
#
onHeadersReceived▸ onHeadersReceived(callback
): void
Listen to the HTTP Response Header event. Will be earlier than the request completion event
Parameters
Name | Type |
---|---|
callback | OnHeadersReceivedCallback |
Returns
void
#
onProgressUpdate▸ onProgressUpdate(callback
): void
Listen to upload progress change events
Parameters
Name | Type |
---|---|
callback | UploadTaskOnProgressUpdateCallback |
Returns
void
#
OffHeadersReceivedCallbackƬ OffHeadersReceivedCallback: (result
: OnHeadersReceivedCallbackResult
) => void
Type declaration
▸ (result
): void
Parameters
Name | Type |
---|---|
result | OnHeadersReceivedCallbackResult |
Returns
void
#
Interface: OnHeadersReceivedCallbackResultName | Type | Description |
---|---|---|
header | Headers | HTTP Response Header returned by the developer server |
#
UploadTaskOffProgressUpdateCallbackƬ UploadTaskOffProgressUpdateCallback: (result
: UploadTaskOnProgressUpdateCallbackResult
) => void
Type declaration
▸ (result
): void
Parameters
Name | Type |
---|---|
result | UploadTaskOnProgressUpdateCallbackResult |
Returns
void
#
Interface: UploadTaskOnProgressUpdateCallbackResultName | Type | Description |
---|---|---|
progress | number | Upload progress percentage |
totalBytesExpectedToSend | number | Expected total length of data to be uploaded, in Bytes |
totalBytesSent | number | The length of the uploaded data, in Bytes |
#
OnHeadersReceivedCallbackƬ OnHeadersReceivedCallback: (result
: OnHeadersReceivedCallbackResult
) => void
Type declaration
▸ (result
): void
Parameters
Name | Type |
---|---|
result | OnHeadersReceivedCallbackResult |
Returns
void
#
UploadTaskOnProgressUpdateCallbackƬ UploadTaskOnProgressUpdateCallback: (result
: UploadTaskOnProgressUpdateCallbackResult
) => void
Type declaration
▸ (result
): void
Parameters
Name | Type |
---|---|
result | UploadTaskOnProgressUpdateCallbackResult |
Returns
void