UNPKG

3.14 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var tslib = require('tslib');
6var core = require('@angular/core');
7var core$1 = require('@ionic-native/core');
8
9var FileTransfer = /** @class */ (function (_super) {
10 tslib.__extends(FileTransfer, _super);
11 function FileTransfer() {
12 var _this = _super !== null && _super.apply(this, arguments) || this;
13 /**
14 * Error code rejected from upload with FileTransferError
15 * Defined in FileTransferError.
16 * FILE_NOT_FOUND_ERR: 1 Return when file was not found
17 * INVALID_URL_ERR: 2, Return when url was invalid
18 * CONNECTION_ERR: 3, Return on connection error
19 * ABORT_ERR: 4, Return on aborting
20 * NOT_MODIFIED_ERR: 5 Return on '304 Not Modified' HTTP response
21 * @enum {number}
22 */
23 _this.FileTransferErrorCode = {
24 FILE_NOT_FOUND_ERR: 1,
25 INVALID_URL_ERR: 2,
26 CONNECTION_ERR: 3,
27 ABORT_ERR: 4,
28 NOT_MODIFIED_ERR: 5,
29 };
30 return _this;
31 }
32 /**
33 * Creates a new FileTransfer object
34 * @return {FileTransferObject}
35 */
36 FileTransfer.prototype.create = function () {
37 return new FileTransferObject();
38 };
39 FileTransfer.pluginName = "FileTransfer";
40 FileTransfer.plugin = "cordova-plugin-file-transfer";
41 FileTransfer.pluginRef = "FileTransfer";
42 FileTransfer.repo = "https://github.com/apache/cordova-plugin-file-transfer";
43 FileTransfer.platforms = ["Amazon Fire OS", "Android", "Browser", "iOS", "Ubuntu", "Windows", "Windows Phone"];
44 FileTransfer.decorators = [
45 { type: core.Injectable }
46 ];
47 return FileTransfer;
48}(core$1.IonicNativePlugin));
49var FileTransferObject = /** @class */ (function () {
50 function FileTransferObject() {
51 if (core$1.checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) {
52 this._objectInstance = new (FileTransfer.getPlugin())();
53 }
54 }
55 FileTransferObject.prototype.upload = function (fileUrl, url, options, trustAllHosts) { return core$1.cordovaInstance(this, "upload", { "successIndex": 2, "errorIndex": 3 }, arguments); };
56 FileTransferObject.prototype.download = function (source, target, trustAllHosts, options) { return core$1.cordovaInstance(this, "download", { "successIndex": 2, "errorIndex": 3 }, arguments); };
57 FileTransferObject.prototype.onProgress = function (listener) {
58 var _this = this;
59 return (function () {
60 if (core$1.instanceAvailability(_this) === true) {
61 _this._objectInstance.onprogress = listener;
62 }
63 })();
64 };
65 FileTransferObject.prototype.abort = function () { return core$1.cordovaInstance(this, "abort", { "sync": true }, arguments); };
66 FileTransferObject.plugin = "cordova-plugin-file-transfer";
67 FileTransferObject.pluginName = "FileTransfer";
68 return FileTransferObject;
69}());
70
71exports.FileTransfer = FileTransfer;
72exports.FileTransferObject = FileTransferObject;