1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/fileSlice_worker.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,27 @@ 1.4 +/** 1.5 + * Expects an object containing a blob, a start offset, an end offset 1.6 + * and an optional content type to slice the blob. Returns an object 1.7 + * containing the size and type of the sliced blob. 1.8 + */ 1.9 +onmessage = function(event) { 1.10 + var blob = event.data.blob; 1.11 + var start = event.data.start; 1.12 + var end = event.data.end; 1.13 + var contentType = event.data.contentType; 1.14 + 1.15 + var slicedBlob; 1.16 + if (contentType == undefined && end == undefined) { 1.17 + slicedBlob = blob.slice(start); 1.18 + } else if (contentType == undefined) { 1.19 + slicedBlob = blob.slice(start, end); 1.20 + } else { 1.21 + slicedBlob = blob.slice(start, end, contentType); 1.22 + } 1.23 + 1.24 + var rtnObj = new Object(); 1.25 + 1.26 + rtnObj.size = slicedBlob.size; 1.27 + rtnObj.type = slicedBlob.type; 1.28 + 1.29 + postMessage(rtnObj); 1.30 +};