Finally fix file upload on Firefox.

This commit is contained in:
Nicolas Stepien 2012-01-22 16:45:34 +01:00
parent c2bd74260b
commit c91b22812f
2 changed files with 15 additions and 5 deletions

View File

@ -1596,7 +1596,7 @@
post.upfile = file;
return qr.message.send(post);
};
reader.readAsArrayBuffer(reply.file);
reader.readAsBinaryString(reply.file);
return;
}
return qr.message.send(post);
@ -1643,7 +1643,7 @@
return postMessage(data, '*');
},
receive: function(data) {
var bb, form, name, url, val, _ref;
var bb, form, i, l, name, ui8a, url, val, _ref;
if (data.abort) {
if ((_ref = qr.ajax) != null) _ref.abort();
return;
@ -1653,8 +1653,13 @@
url = "http://sys.4chan.org/" + data.board + "/post?" + (Date.now());
delete data.board;
if (engine === 'gecko' && data.upfile) {
l = data.upfile.buffer.length;
ui8a = new Uint8Array(l);
for (i = 0; 0 <= l ? i < l : i > l; 0 <= l ? i++ : i--) {
ui8a[i] = data.upfile.buffer.charCodeAt(i);
}
bb = new MozBlobBuilder();
bb.append(data.upfile.buffer);
bb.append(ui8a.buffer);
data.upfile = bb.getBlob(data.upfile.type);
}
form = new FormData();

View File

@ -1216,7 +1216,7 @@ qr =
file.type = reply.file.type
post.upfile = file
qr.message.send post
reader.readAsArrayBuffer reply.file
reader.readAsBinaryString reply.file
return
qr.message.send post
@ -1274,8 +1274,13 @@ qr =
url = "http://sys.4chan.org/#{data.board}/post?#{Date.now()}"
delete data.board
if engine is 'gecko' and data.upfile
# binary string to ArrayBuffer code from Aeosynth's 4chan X
l = data.upfile.buffer.length
ui8a = new Uint8Array l
for i in [0...l]
ui8a[i] = data.upfile.buffer.charCodeAt i
bb = new MozBlobBuilder()
bb.append data.upfile.buffer
bb.append ui8a.buffer
data.upfile = bb.getBlob data.upfile.type
form = new FormData()
for name, val of data