diff --git a/cordova/cordova-tests.ts b/cordova/cordova-tests.ts index dfaa25cc3..e635535ac 100644 --- a/cordova/cordova-tests.ts +++ b/cordova/cordova-tests.ts @@ -177,6 +177,20 @@ file.download('http://some.server.com/download.php', { headers: null }, true); +file.upload('cdvfile://localhost/persistent/path/to/downloads/', + 'http://some.server.com/download.php', + (result: FileUploadResult)=> { console.log('File uploaded. Bytes uploaded: ' + result.bytesSent); }, + (err: FileTransferError) => { + console.error('Error ' + err.code); + if (err.exception) { + console.error('Failed with exception ' + err.exception); + } + }, + { headers: null, httpMethod: "PUT" }, + true); + +file.abort(); + file.abort(); diff --git a/cordova/plugins/Device.d.ts b/cordova/plugins/Device.d.ts index 8365ee70f..283406cb9 100644 --- a/cordova/plugins/Device.d.ts +++ b/cordova/plugins/Device.d.ts @@ -18,8 +18,6 @@ interface Device { * by the device manufacturer and may be different across versions of the same product. */ model: string; - /** device.name is deprecated as of version 2.3.0. Use device.model instead. */ - name: string; /** Get the device's operating system name. */ platform: string; /** Get the device's Universally Unique Identifier (UUID). */ diff --git a/cordova/plugins/FileTransfer.d.ts b/cordova/plugins/FileTransfer.d.ts index 457c9daf2..d0c023ae8 100644 --- a/cordova/plugins/FileTransfer.d.ts +++ b/cordova/plugins/FileTransfer.d.ts @@ -84,6 +84,8 @@ interface FileUploadOptions { fileKey?: string; /** The file name to use when saving the file on the server. Defaults to image.jpg. */ fileName?: string; + /** The HTTP method to use - either `PUT` or `POST`. Defaults to `POST`. */ + httpMethod?: string; /** The mime type of the data to upload. Defaults to image/jpeg. */ mimeType?: string; /** A set of optional key/value pairs to pass in the HTTP request. */ @@ -108,6 +110,7 @@ interface FileTransferError { * FileTransferError.INVALID_URL_ERR * FileTransferError.CONNECTION_ERR * FileTransferError.ABORT_ERR + * FileTransferError.NOT_MODIFIED_ERR */ code: number; /** URL to the source. */ @@ -116,8 +119,8 @@ interface FileTransferError { target: string; /** HTTP status code. This attribute is only available when a response code is received from the HTTP connection. */ http_status: number; - /* Request body */ - body: any; + /* Response body. This attribute is only available when a response is received from the HTTP connection. */ + body: string; /* Exception that is thrown by native code */ exception: any; } @@ -129,4 +132,5 @@ declare var FileTransferError: { INVALID_URL_ERR: number; CONNECTION_ERR: number; ABORT_ERR: number; + NOT_MODIFIED_ERR: number; } \ No newline at end of file