New Blob Constructor in IE10
IE10 in Windows 8 Release Preview adds support for a Blob
constructor. We earlier wrote about and demonstrated IE10’s support for a BlobBuilder
interface, an in-progress interface in the File API: Writer W3C Working Draft. This interface enables developers to work with files on the client PC. Recently, the W3C working group deprecated the BlobBuilder
interface in favor of a new Blob
constructor. This post explains the differences between the two.
Comparing Blob Constructor and BlobBuilder Interface
Both the Blob
constructor and the BlobBuilder
interface enable Web developers to create files on the client. The difference is in the syntax. Whereas BlobBuilder
requires each portion of the blob to be appended during a separate call to the append method, the Blob
constructor can take an array of arguments. Here’s how to create a simple text file using both BlobBuilder
and the Blob
constructor:
// using the Blob constructor
var textBlob1 = new Blob(["Hello", " world!"], { type: "text/plain", endings: "transparent" });
// using the MSBlobBuilder interface
var bb = new MSBlobBuilder();
bb.append("Hello");
bb.append(" world!");
var textBlob2 = bb.getBlob("text/plain");
The Blob
constructor takes two arguments, the array of content to put into the blob and an optional dictionary object which can include two members, type
and endings
. The array of content for the blob may contain blob objects, text strings or array buffers.
Recent versions of Firefox and Chrome also support the Blob
constructor. IE10 still supports the prefixed MSBlobBuilder
interface in addition to the new Blob
constructor. At this time, Firefox and Chrome also support their vendor-prefixed BlobBuilder
interface.
Feature Detecting the Blob Constructor
As with all new features, we recommend using feature detection to determine if the Blob
constructor is available in the browser your code is running on. You can use something like this:
if (typeof Blob !== "undefined") {
// use the Blob constructor
} else if (window.MSBlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder) {
// use the supported vendor-prefixed BlobBuilder
} else {
// neither Blob constructor nor BlobBuilder is supported
}
If you run the BlobBuilder
Test Drive demo with the F12 developer tools console window open, it will log whether the blobs are being built via the Blob
constructor or via BlobBuilder
.
The addition of the Blob
constructor to IE10 enables you to write standards-compliant code that works across browsers.
—Sharon Newman, Program Manager, Internet Explorer
Comments
Anonymous
July 20, 2012
This is good progress on the File API, both from W3C and MS. But will MSBlobBuilder be removed? Seems pointless to keep it around with the final release of IE10.Anonymous
July 20, 2012
I made the following short script which will normalize existing BlobBuilder interfaces to the new Blob constructor interface and also normalize prefixes. The Blob constructor interface exposes the same total functionality as the BlobBuilder, so it's possible to fully shim in support fornew Blob
if you have `BlobBuilder. gist.github.com/2793006 void function(){ function resolvePrefix(name, o){ o = o || window; var cased = name[0].toUpperCase() + name.slice(1); return ['', '', 'Moz', 'WebKit', 'Ms', 'O'].reduce(function(r, s){ return r || o[s + name] || o[s.toLowerCase() + cased]; }); } var VendorBlob = resolvePrefix('Blob'); if (VendorBlob === undefined) return; VendorBlob.prototype.slice = resolvePrefix('slice', VendorBlob.prototype); try { new VendorBlob; return window.Blob = VendorBlob; } catch (e) {} var VendorBlobBuilder = resolvePrefix('BlobBuilder'); function Blob(parts, properties){ var builder = new VendorBlobBuilder; var type = (properties && properties.type) || ''; var endings = (properties && properties.endings) || ''; if (Array.isArray(parts)) { parts.forEach(function(part){ if (typeof part === 'string') builder.append(part, endings); else builder.append(part); }); } return builder.getBlob(type); } Blob.prototype = VendorBlob.prototype; window.Blob = Blob; }();Anonymous
July 20, 2012
The comment has been removedAnonymous
July 20, 2012
@warrens: MSBlobBuilder will remain in IE10 to support sites and apps which may have adopted it between its first introduction and Windows 8 Release Preview.Anonymous
July 20, 2012
If MSBlobBuilder remains, at the very least it should put a warning in the console advising not to use it and switch to Blob instead. And state clearly that it will be removed in the next release. The shorter that API is out there, the less chance that someone missuses it.Anonymous
July 20, 2012
@Microsofts Monday July 23rd Agenda: Are you planning to post this comment on every blogpost? By the way: its the July 21st. @TS: Nice! Date for launch of IE10?Anonymous
July 20, 2012
@Yannick Hey, he is right. It's weekend. 21st & 22nd are holidays. Next working day is 23rd.Anonymous
July 21, 2012
Good and all, but not a soul can use it, since YOU REFUSE TO RELEASE A WIN7 VERSION. Opera releases snapshot at least weekly, and those snapshots practically run on every existing system.Anonymous
July 21, 2012
Calm down, IE10 will be RTMed for Win7 too, it's just dev version not available.Anonymous
July 21, 2012
Microsoft you are seriously messed up!!! If you created a temp MSBlobBuilder implementation in an alpha/beta browser while it was under construction and now it's done then SHIP IT with the final unprefixed name!!! No Exceptions!!!! You only maintain legacy support for RTM'd features. Do not waste our time with adding proprietary features to IE10 that are going to be removed later when you haven't shipped yet!!! Heck you haven't even released IE10 beta for developers yet!! (win7 version that we've been waiting for!!!)Anonymous
July 21, 2012
@Klimax If Microsoft wants to sale at least some Win8, they shouldn't release IE10 on Win7. I say that because I don't see any other reason why a sane person would downgrade their OS from win7 to Win8.Anonymous
July 21, 2012
It doesn't matter if they release ie10 on windows7, because if ie10 is so slow as ie9 on win7 then the don't have to release it, because people will use googlechroome or firefox or opera instead, much faster and it will not slow down while surfing as with ie9 + ie10Anonymous
July 21, 2012
The comment has been removedAnonymous
July 21, 2012
The comment has been removedAnonymous
July 22, 2012
The comment has been removedAnonymous
July 22, 2012
The blob support is great. I created a basic sample creating dynamic audio on jsfiddle.net/.../HkNXkAnonymous
July 23, 2012
can someone please tell us when IE10 will be released in windows7 as Beta ??? ??Anonymous
July 23, 2012
I'm sorry, @Walter, but I really don't understand your problem. Boot up is MUCH faster. Directly to start screen. Your commonly used desktop apps are then right there on that screen... click and go. Any other apps you use in desktop are pinned to the taskbar. There are no "additional steps". You're still getting to your apps FASTER than before. I don't undrstand what you're complaining about.Anonymous
July 23, 2012
The comment has been removedAnonymous
July 23, 2012
The comment has been removedAnonymous
July 23, 2012
The comment has been removedAnonymous
July 23, 2012
The comment has been removedAnonymous
July 23, 2012
The comment has been removedAnonymous
July 23, 2012
The comment has been removedAnonymous
July 24, 2012
The comment has been removedAnonymous
July 24, 2012
The comment has been removedAnonymous
July 24, 2012
We have updated the release date for IE10. It looks like we will get the IE10 RTM very soonish. Microsoft will supposedly release Windows 8 RTM in early August. Together with the RTM release ships a copy of IE10 RTM.Anonymous
July 24, 2012
@Eric - OMG! Are you serious? Neither Windows 8 nor IE10 is ready for prime time! please point to your source! We haven't even had the IE10 Beta on Windows 7 yet! (when the f_u_d_g_e was Microsoft thinking we were going to do ALL OF OUR TESTING?!?!?)Anonymous
July 24, 2012
The comment has been removedAnonymous
July 24, 2012
The comment has been removedAnonymous
July 24, 2012
The comment has been removedAnonymous
July 24, 2012
The comment has been removedAnonymous
July 25, 2012
I am unable to test IE10, does it support the CSS3 tab-size property? If not, the IE team should consider adding support =]Anonymous
July 25, 2012
The comment has been removedAnonymous
July 25, 2012
The comment has been removedAnonymous
July 25, 2012
@acidcode Actually all my attempts at virtualizing windows 8 failed, it doesn't like something on my laptop. But anyway, while this prerelease situation has been less than ideal, they did confirm a very long time ago that there would be a release candidate version for Windows 7 before IE10 is done. blogs.msdn.com/.../html5-for-applications-the-fourth-ie10-platform-preview.aspxAnonymous
July 25, 2012
The comment has been removedAnonymous
July 25, 2012
The comment has been removedAnonymous
July 25, 2012
The comment has been removedAnonymous
July 26, 2012
The comment has been removedAnonymous
July 26, 2012
The comment has been removedAnonymous
July 26, 2012
@Steve, (the last post was addressed to you as well). I totally agree with you on point #2 and #4, I suppose you have submitted the bug report on the issue tracker at http://connect.microsoft.com? Please send us the link so we can vote up. You see blog comment is not a place to send a bug report.Anonymous
July 26, 2012
The comment has been removedAnonymous
July 26, 2012
The comment has been removedAnonymous
July 26, 2012
The comment has been removedAnonymous
July 27, 2012
The comment has been removedAnonymous
July 30, 2012
@Gord, then what on the earth you are doing here on MSDN blog? Embarrasing yourself? GTFOH you trolling pigs.Anonymous
July 30, 2012
The comment has been removedAnonymous
July 30, 2012
@Xero - I appreciate your passion, but like most I poured hundreds of hours into connect filing legit bug reports, with test cases (not feature requests) and Microsoft sat on all of them... if I got a response it was "can't reproduce" even though it was 100% reproducible in very simple steps. In the end they all got marked as Won't Fix or By Design (or both) with no explanation. Any that were re-opened (with explanation) were again sat on, and re-closed later on... and then NOT PORTED to the next IE release in Connect when it the next release started to track bugs. I (like all the submitters) was ABSOLUTELY LIVID!!!!!! that all the work was lost... hundreds of hours down the drain. Like everyone else now... I have ZERO INTEREST WHATSOEVER in participating in bug reporting for Internet Explorer now UNLESS Microsoft comes on the IE BLOG and COMMITS to running public, open bug tracking properly (where users can review test cases and confirm them) and Microsoft COMMITS to porting over the open bugs into the new system whenever there is an IE release... I DON'T DO THROWAWAY WORK (esp. when it is VOLUNTARY!)Anonymous
July 31, 2012
@Steve. well I don't think everyone else is so biased about it. People are contributing on Connect regularly on daily basis. 100 of hours! Then you must have submitted tons of bugs there. Give us the URL of some reports where you have 100% legit reproducible bug and they closed it as "can't reproduce".