@ionic-native/file-transfer
Version:
Ionic Native - Native plugins for ionic apps
73 lines (68 loc) • 3.14 kB
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var core = require('@angular/core');
var core$1 = require('@ionic-native/core');
var FileTransfer = /** @class */ (function (_super) {
tslib.__extends(FileTransfer, _super);
function FileTransfer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* Error code rejected from upload with FileTransferError
* Defined in FileTransferError.
* FILE_NOT_FOUND_ERR: 1 Return when file was not found
* 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}
*/
_this.FileTransferErrorCode = {
FILE_NOT_FOUND_ERR: 1,
INVALID_URL_ERR: 2,
CONNECTION_ERR: 3,
ABORT_ERR: 4,
NOT_MODIFIED_ERR: 5,
};
return _this;
}
/**
* Creates a new FileTransfer object
* @return {FileTransferObject}
*/
FileTransfer.prototype.create = function () {
return new FileTransferObject();
};
FileTransfer.pluginName = "FileTransfer";
FileTransfer.plugin = "cordova-plugin-file-transfer";
FileTransfer.pluginRef = "FileTransfer";
FileTransfer.repo = "https://github.com/apache/cordova-plugin-file-transfer";
FileTransfer.platforms = ["Amazon Fire OS", "Android", "Browser", "iOS", "Ubuntu", "Windows", "Windows Phone"];
FileTransfer.decorators = [
{ type: core.Injectable }
];
return FileTransfer;
}(core$1.IonicNativePlugin));
var FileTransferObject = /** @class */ (function () {
function FileTransferObject() {
if (core$1.checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) {
this._objectInstance = new (FileTransfer.getPlugin())();
}
}
FileTransferObject.prototype.upload = function (fileUrl, url, options, trustAllHosts) { return core$1.cordovaInstance(this, "upload", { "successIndex": 2, "errorIndex": 3 }, arguments); };
FileTransferObject.prototype.download = function (source, target, trustAllHosts, options) { return core$1.cordovaInstance(this, "download", { "successIndex": 2, "errorIndex": 3 }, arguments); };
FileTransferObject.prototype.onProgress = function (listener) {
var _this = this;
return (function () {
if (core$1.instanceAvailability(_this) === true) {
_this._objectInstance.onprogress = listener;
}
})();
};
FileTransferObject.prototype.abort = function () { return core$1.cordovaInstance(this, "abort", { "sync": true }, arguments); };
FileTransferObject.plugin = "cordova-plugin-file-transfer";
FileTransferObject.pluginName = "FileTransfer";
return FileTransferObject;
}());
exports.FileTransfer = FileTransfer;
exports.FileTransferObject = FileTransferObject;
;