diff options
author | Peter Grassberger <petertheone@gmail.com> | 2016-07-22 14:20:12 (GMT) |
---|---|---|
committer | Peter Grassberger <petertheone@gmail.com> | 2016-07-22 14:20:12 (GMT) |
commit | 3f428828c7db98a7606a9f4902fa017758bfadfb (patch) | |
tree | 4fef5519c02a576a32d98e658e74efda35a5f697 /www | |
parent | 2e7b6a5bd5588413b7729970f0619d9bd8d2a2a1 (diff) |
replace websocket file upload with post
needs more work
Diffstat (limited to 'www')
-rw-r--r-- | www/js/importer.js | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/www/js/importer.js b/www/js/importer.js index 6dfba76..2a96ff7 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -373,7 +373,21 @@ Rdxport.Upload.prototype.onmessage = function(event) { this.importFileUploadError(data.RESPONSE_CODE, data.ERROR_STRING); break; case Rdxport.Importer.TYPE_ACK: - //console.log(data); + console.log(data); + if (this.file && !this.sendingFile) { + this.sendingFile = true; + + // todo: post request goes here. + /*var command = { + LOGIN_NAME: this.username, + SESSION_ID: data.ID, + FILENAME: 'filename!', + data: self.file, + mimeTypes:"multipart/form-data" + }; + return $.post('https://import.helsinki.at/upload', command);*/ + } + this.group.fetchCarts(); this.groupView.uploadProgress(this); break; @@ -404,32 +418,6 @@ Rdxport.Upload.prototype.onmessage = function(event) { } break; } - - if (this.file && !this.sendingFile) { - this.sendingFile = true; - - var chunkSize = 60 * 1024; - var start = 0; - var end = chunkSize; - var self = this; - this.uploadInterval = setInterval(function() { - for(var i = 0; i < 16; i++) { - if (self.webSocket.bufferedAmount > 16 * chunkSize) { - return true; - } - var blob = self.file.slice(start, end, {type: "application/octet-stream"}); - self.webSocket.send(blob); - - if (self.file.size === end) { - clearInterval(self.uploadInterval); - return true; - } - start += chunkSize; - end += chunkSize; - end = end > self.file.size ? self.file.size : end; - } - }, 50); - } }; Rdxport.Upload.prototype.import = function() { @@ -463,7 +451,7 @@ Rdxport.Upload.prototype.import = function() { AUTOTRIM_LEVEL: self.group.trimlevel, USE_METADATA: self.useMetadata, REFERENCE_ID: reference - }; + }; if (self.group instanceof Rdxport.Show) { sendOptions.SHOW_ID = self.group.id; } |