This is mostly just an announcement (since I forgot to send out the
initial mail requesting a code review).
I have just submitted 8226669, which introduces a new
JavaScript-visible BlobBuilder module, where one can concatenate
strings and blobs together to make one big blob. A particular use case
is allowing a GearsHttpRequest to upload multiple files in the same
multipart format that an HTML form does. Example code looks like this:
var file = ...; // As received from desktop.openFiles().
var boundary = '------multipartformboundary' + someRandomAlphaNumerics;
var dashDash = '--';
var crlf = '\r\n';
var dashDashBoundaryCrlf = dashDash + boundary + crlf;
var blobBuilder = google.gears.factory.create('beta.blobbuilder');
builder.append(dashDashBoundaryCrlf);
builder.append('Content-Disposition: form-data; name="' + name + '"');
if (file.name) {
builder.append('; filename="' + file.name + '"');
}
builder.append(crlf);
builder.append('Content-Type: application/octet-stream');
builder.append(crlf);
builder.append(crlf);
builder.append(file.blob);
builder.append(crlf);
builder.append(dashDash);
builder.append(boundary);
builder.append(dashDash);
builder.append(crlf);
var request = google.gears.factory.create('beta.httprequest');
request.open('POST', '...');
request.setRequestHeader('content-type', 'multipart/form-data;
boundary=' + boundary);
request.send(blobBuilder.getAsBlob());