Blob from binary string javascript
1 answer
Is the blob you are using is not available for use?
Do you need to use readAsBinaryString
? Can you use readAsArrayBuffer
. With an array buffer, it would be much easier to recreate the blob.
If you couldn't link its blob by looping through the line and building a byte array, creating blobs from it.
$('input').change(function(){
var frb = new FileReader();
frb.onload = function(){
var i, l, d, array;
d = this.result;
l = d.length;
array = new Uint8Array(l);
for (var i = 0; i < l; i++){
array[i] = d.charCodeAt(i);
}
var b = new Blob([array], {type: 'application/octet-stream'});
window.location.href = URL.createObjectURL(b);
};
frb.readAsBinaryString(this.files[0]);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input type="file">
+8
source to share