mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2026-04-28 00:02:49 +08:00
Merge branch 'master' of https://github.com/ABB-Austin/cordova-plugin-file-transfer
This commit is contained in:
@@ -182,6 +182,9 @@ A `FileUploadResult` object is passed to the success callback of the
|
|||||||
|
|
||||||
- Does not support `responseCode` or `bytesSent`.
|
- Does not support `responseCode` or `bytesSent`.
|
||||||
|
|
||||||
|
### Browser Quirks
|
||||||
|
|
||||||
|
- __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest
|
||||||
|
|
||||||
## download
|
## download
|
||||||
|
|
||||||
@@ -230,6 +233,10 @@ __Parameters__:
|
|||||||
|
|
||||||
- Download requests is being cached by native implementation. To avoid caching, pass `if-Modified-Since` header to download method.
|
- Download requests is being cached by native implementation. To avoid caching, pass `if-Modified-Since` header to download method.
|
||||||
|
|
||||||
|
### Browser Quirks
|
||||||
|
|
||||||
|
- __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest
|
||||||
|
|
||||||
## abort
|
## abort
|
||||||
|
|
||||||
Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object which has an error code of FileTransferError.ABORT_ERR.
|
Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object which has an error code of FileTransferError.ABORT_ERR.
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
|||||||
var fileName = options.fileName || "image.jpg";
|
var fileName = options.fileName || "image.jpg";
|
||||||
var mimeType = options.mimeType || "image/jpeg";
|
var mimeType = options.mimeType || "image/jpeg";
|
||||||
var params = options.params || {};
|
var params = options.params || {};
|
||||||
|
var withCredentials = options.withCredentials || false;
|
||||||
// var chunkedMode = !!options.chunkedMode; // Not supported
|
// var chunkedMode = !!options.chunkedMode; // Not supported
|
||||||
var headers = options.headers || {};
|
var headers = options.headers || {};
|
||||||
var httpMethod = options.httpMethod && options.httpMethod.toUpperCase() === "PUT" ? "PUT" : "POST";
|
var httpMethod = options.httpMethod && options.httpMethod.toUpperCase() === "PUT" ? "PUT" : "POST";
|
||||||
@@ -121,6 +122,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
|||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
var xhr = transfers[this._id] = new XMLHttpRequest();
|
var xhr = transfers[this._id] = new XMLHttpRequest();
|
||||||
|
xhr.withCredentials = withCredentials;
|
||||||
|
|
||||||
var fail = errorCallback && function(code, status, response) {
|
var fail = errorCallback && function(code, status, response) {
|
||||||
transfers[this._id] && delete transfers[this._id];
|
transfers[this._id] && delete transfers[this._id];
|
||||||
@@ -222,6 +224,7 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var headers = options.headers || {};
|
var headers = options.headers || {};
|
||||||
|
var withCredentials = options.withCredentials || false;
|
||||||
|
|
||||||
var basicAuthHeader = getBasicAuthHeader(source);
|
var basicAuthHeader = getBasicAuthHeader(source);
|
||||||
if (basicAuthHeader) {
|
if (basicAuthHeader) {
|
||||||
@@ -231,7 +234,7 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
|
|||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
var xhr = transfers[this._id] = new XMLHttpRequest();
|
var xhr = transfers[this._id] = new XMLHttpRequest();
|
||||||
|
xhr.withCredentials = withCredentials;
|
||||||
var fail = errorCallback && function(code, status, response) {
|
var fail = errorCallback && function(code, status, response) {
|
||||||
transfers[that._id] && delete transfers[that._id];
|
transfers[that._id] && delete transfers[that._id];
|
||||||
// In XHR GET reqests we're setting response type to Blob
|
// In XHR GET reqests we're setting response type to Blob
|
||||||
|
|||||||
Reference in New Issue
Block a user