Browse - Programming Tips - How can I convert a Blob to a File?

Date: 2016may10
Language: javaScript
Platform: web

Q.  How can I convert a Blob to a File?

A.  The File constructor accepts a Blob but not in all browsers
so this seems like the best way:

function blobToFile(myblob, name) { var file = null; try { file = new File([myblob], name); } catch(error) { file = myblob; file.lastModifiedDate = new Date(); file.name = name; } return file; }