docs(filetransfer): Improve docs for FileTransferError and wrap existing usage in ts (#329)

* Improve docs for FileTransferError and wrap existing usage in ts

* Add closing code tag

* Doubled space between param name and description
This commit is contained in:
Marcin Wadoń 2016-07-19 10:28:48 +02:00 committed by Ibrahim Hadeed
parent 5979e9a8b0
commit a8fa61ddb9

View File

@ -107,19 +107,32 @@ export interface FileTransferError {
/** /**
* @name Transfer * @name Transfer
* @description This plugin allows you to upload and download files. *
* Example: * @description
* This plugin allows you to upload and download files.
*
* @usage
*
* Create instance: * Create instance:
* ```ts
* const fileTransfer = new Transfer(); * const fileTransfer = new Transfer();
* ```
* *
* Upload a file: * Upload a file:
* ```ts
* fileTransfer.upload(..).then(..).catch(..); * fileTransfer.upload(..).then(..).catch(..);
* ```
* *
* Download a file: * Download a file:
* ```ts
* fileTransfer.download(..).then(..).catch(..); * fileTransfer.download(..).then(..).catch(..);
* ```
* *
* Abort active transfer: * Abort active transfer:
* ```ts
* fileTransfer.abort(); * fileTransfer.abort();
* ```
*
*/ */
@Plugin({ @Plugin({
plugin: 'cordova-plugin-file-transfer', plugin: 'cordova-plugin-file-transfer',
@ -128,11 +141,23 @@ export interface FileTransferError {
}) })
export class Transfer { export class Transfer {
public static FILE_NOT_FOUND_ERR: number = 1; /**
public static INVALID_URL_ERR: number = 2; * Error code rejected from upload with FileTransferError
public static CONNECTION_ERR: number = 3; * Defined in FileTransferError.
public static ABORT_ERR: number = 4; * FILE_NOT_FOUND_ERR: 1 Return when file was not found
public static NOT_MODIFIED_ERR: number = 4; * INVALID_URL_ERR: 2, Return when url was invalid
* CONNECTION_ERR: 3, Return on connection error
* ABORT_ERR: 4, Return on aborting
* NOT_MODIFIED_ERR: 5 Return on "304 Not Modified" HTTP response
* @enum {number}
*/
public static FileTransferErrorCode = {
FILE_NOT_FOUND_ERR: 1,
INVALID_URL_ERR: 2,
CONNECTION_ERR: 3,
ABORT_ERR: 4,
NOT_MODIFIED_ERR: 5
};
private _objectInstance: any; private _objectInstance: any;
@ -146,7 +171,7 @@ export class Transfer {
* @param {string} fileUrl Filesystem URL representing the file on the device or a data URI. For backwards compatibility, this can also be the full path of the file on the device. * @param {string} fileUrl Filesystem URL representing the file on the device or a data URI. For backwards compatibility, this can also be the full path of the file on the device.
* @param {string} url URL of the server to receive the file, as encoded by encodeURI(). * @param {string} url URL of the server to receive the file, as encoded by encodeURI().
* @param {FileUploadOptions} options Optional parameters. * @param {FileUploadOptions} options Optional parameters.
* @param {boolean} trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. * @param {boolean} trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
* @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError. * @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError.
*/ */
@CordovaInstance({ @CordovaInstance({