/** * The Download class which is used to represent a downloading file. It's a promise- * like object that also supports a simple event interface for providing progress * notifications. You normally don't create these yourself; they're the objects * returned by the Download API: * * var download = Ext.space.Downloads.download({ url: "http://example.com/" }); * * // get the File object (and the completed Download object) * download.then(function(file, finishedDownload) { * // do something with the file * Ext.space.Logger.log(file instanceof Ext.space.files.File); // true * Ext.space.Logger.log(finishedDownload instanceof Ext.space.files.Download); // true * }); * * // get progress updates * download.on("progress", function(updatedDownload) { * // inspect the latest data * }); * * // cancel the download * download.cancel().then(function() { * // done * }); * */Ext.define("Ext.space.files.Download", { extend: Ext.space.files.Transfer, /** * @private */ manager: Ext.space.Downloads, /** * @private */ idField: "downloadId", /** * Internal identifier for this download * @type {String} */ downloadId: null, /** * MIME type * @type {String} */ mimeType: null, /** * @private */ bytesTransferredField: "bytesDownloaded", /** * Progress so far * @type {Number} */ bytesDownloaded: 0, /** * Whether the file is moved from the temporary download storage * @type {Boolean} */ isVolatile: true, /** * Destination file path/name * @type {String} */ fileName: null, /** * @private */ constructor: function(args) { Ext.space.files.Download.superclass.constructor.apply(this, [args]); }, /** * Bulk update this download with the data provided. * * @private * @param {Object} source Object with data to overwrite onto this Download */ _updateWith: function(source) { if (source) { if (source.mimeType) { this.mimeType = source.mimeType; } if (source.fileName) { this.fileName = source.fileName; } if (source.hasOwnProperty("isVolatile")) { this.isVolatile = source.isVolatile; } } return Ext.space.files.Download.superclass._updateWith.apply(this, arguments); }});