Perform chunked uploads from upload dialog
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.Upload.js
index 4a463b0..7e6cfb6 100644 (file)
@@ -2,8 +2,6 @@
        var UP;
 
        /**
-        * @class mw.Upload
-        *
         * Used to represent an upload in progress on the frontend.
         * Most of the functionality is implemented in mw.Api.plugin.upload,
         * but this model class will tie it together as well as let you perform
@@ -43,6 +41,8 @@
         *       } );
         *     } );
         *
+        * @class mw.Upload
+        *
         * @constructor
         * @param {Object|mw.Api} [apiconfig] A mw.Api object (or subclass), or configuration
         *     to pass to the constructor of mw.Api.
                this.filename = filename;
        };
 
+       /**
+        * Set the stashed file to finish uploading.
+        *
+        * @param {string} filekey
+        */
+       UP.setFilekey = function ( filekey ) {
+               var upload = this;
+
+               this.setState( Upload.State.STASHED );
+               this.stashPromise = $.Deferred().resolve( function ( data ) {
+                       return upload.api.uploadFromStash( filekey, data );
+               } );
+       };
+
        /**
         * Sets the filename based on the filename as it was on the upload.
         */
 
                this.setState( Upload.State.UPLOADING );
 
-               return this.api.upload( this.getFile(), {
+               return this.api.chunkedUpload( this.getFile(), {
                        watchlist: ( this.getWatchlist() ) ? 1 : undefined,
                        comment: this.getComment(),
                        filename: this.getFilename(),
 
                this.setState( Upload.State.UPLOADING );
 
-               this.stashPromise = this.api.uploadToStash( this.getFile(), {
+               this.stashPromise = this.api.chunkedUploadToStash( this.getFile(), {
                        filename: this.getFilename()
                } ).then( function ( finishStash ) {
                        upload.setState( Upload.State.STASHED );