application/js/sharded_upload.js in spontaneous-0.2.0.beta1 vs application/js/sharded_upload.js in spontaneous-0.2.0.beta2
- old
+ new
@@ -30,11 +30,11 @@
this.hash = sha
this.begin_upload();
this.failure_count = 0;
},
remote_path: function() {
- return S.Ajax.request_url(['shard', this.hash].join('/'), true);
+ return S.Ajax.request_url(['shard', this.hash].join('/'));
},
begin_upload: function() {
// test for existance of shard on server
S.Ajax.get(['/shard', this.hash].join('/'), this.status_complete.bind(this));
},
@@ -55,14 +55,16 @@
},
upload: function() {
// create the form and post it using the calculated hash
// assigning the callbacks to myself.
- var form = new FormData(),
- path = S.Ajax.request_url(['/shard', this.hash].join('/'), true);
+ var form = new FormData()
+ , path = S.Ajax.request_url(['/shard', this.hash].join('/'));
form.append('file', this.blob);
- var xhr = new XMLHttpRequest(), upload = xhr.upload;
+ var xhr = S.Ajax.authenticatedRequest();
+ var upload = xhr.upload;
+
xhr.open("POST", path, true);
upload.onprogress = this.onprogress.bind(this);
upload.onload = this.onload.bind(this);
upload.onloadend = this.onloadend.bind(this);
upload.onerror = this.onerror.bind(this);
@@ -139,14 +141,15 @@
form.append('field', this.field_name);
form.append('version', this.target_version);
form.append('shards', this.hashes().join(','));
form.append('mime_type', this.mime_type());
form.append('filename', File.filename(this.file));
- this.post(this.path(), form);
+ this.request(this.method, this.path(), form);
},
path: function() {
- return ["/shard/replace", this.target_id].join('/');
+ return ["/shard", this.target_id].join('/');
},
+ method: "PUT",
hashes: function() {
var hashes = [];
for (var i = 0, ii = this.completed.length; i < ii; i++) {
hashes.push(this.completed[i].hash);
}