Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

files.upload

files.upload

This method offers alternative signatures:

files.upload(fileToUpload, [options], [trustAllHosts])

Signature

files.upload(fileToUpload, [options], [trustAllHosts])

Description

Uploads a file from the device's file system to Backend Services. Wraps the Apache Cordova "upload()" FileTransfer method. Note that the signatures of these methods differ.

Return Type

Promise - The promise for the request.

Parameters

Parameter Name Type Default Description
fileToUpload string An Apache Cordova FileSystem URL representing the full path to the file on the device.
[options] object Additional request options. Maps to the "options" FileTransfer plugin parameter.
[options.fileKey] string The name of the form element. Defaults to 'file' in the FileTransfer plugin parameter.
[options.fileName] string The file name to use when uploading the file. Defaults to 'image.jpg' in the FileTransfer plugin.
[options.httpMethod] string The HTTP method to use, either POST or PUT. Defaults to 'POST' in the FileTransfer plugin parameter.
[options.mimeType] string The mime type of the uploaded data. Defaults to 'image/jpeg' in the FileTransfer plugin parameter.
[options.params] object A set of optional key/value pairs to pass in the HTTP request.
[options.chunkedMode] boolean Whether to upload the data in chunked streaming mode. Defaults to 'true' in the FileTransfer plugin parameter.
[options.headers] object A JSON object for the headers to send along with the request.
[trustAllHosts] boolean false Whether to accept all security certificates including self-signed certificates. Maps to the "trustAllHosts" FileTransfer plugin parameter.


files.upload(fileToUpload, [options], [trustAllHosts], [success], [error])

Signature

files.upload(fileToUpload, [options], [trustAllHosts], [success], [error])

Description

Uploads a file from the device's file system to Backend Services. Wraps the Apache Cordova "upload()" FileTransfer method. Note that the signatures of these methods differ.

Parameters

Parameter Name Type Default Description
fileToUpload string An Apache Cordova FileSystem URL representing the full path to the file on the device.
[options] object Additional request options. Maps to the "options" FileTransfer plugin parameter.
[options.fileKey] string The name of the form element. Defaults to 'file' in the FileTransfer plugin parameter.
[options.fileName] string The file name to use when uploading the file. Defaults to 'image.jpg' in the FileTransfer plugin parameter.
[options.httpMethod] string The HTTP method to use, either POST or PUT. Defaults to 'POST' in the FileTransfer plugin parameter.
[options.mimeType] string The mime type of the uploaded data. Defaults to 'image/jpeg' in the FileTransfer plugin parameter.
[options.params] object A set of optional key/value pairs to pass in the HTTP request.
[options.chunkedMode] boolean Whether to upload the data in chunked streaming mode. Defaults to 'true' in the FileTransfer plugin parameter.
[options.headers] object A JSON object for the headers to send along with the request.
[trustAllHosts] boolean false Whether to accept all security certificates including self-signed certificates. Maps to the "trustAllHosts" FileTransfer plugin parameter.
[success] function A success callback that is passed an Apache Cordova FileUploadResult object. Maps to the "successCallback" FileTransfer plugin parameter.
[error] function An error callback that is passed an Apache Cordova FileTransferError object. Maps to the "errorCallback" FileTransfer plugin parameter.


Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.