Skip to content

Instantly share code, notes, and snippets.

@amka
Created May 31, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amka/7829080de53f699d5babf11fb3027ba6 to your computer and use it in GitHub Desktop.
Save amka/7829080de53f699d5babf11fb3027ba6 to your computer and use it in GitHub Desktop.
function getFileObject (fileObject, callback) {
var blob = null;
var xhr = new XMLHttpRequest();
xhr.open("GET", fileObject.path);
xhr.responseType = "blob";
// Process onload event: create new File object and call callback function.
xhr.onload = () => {
blob = xhr.response;
blob.name = fileObject.name;
blob.lastModifiedDate = new Date();
let file = new File([blob], fileObject.name);
callback(file);
};
xhr.send()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment