Skip to content

Instantly share code, notes, and snippets.

@gonzalo-trenco
Last active May 26, 2017 08:33
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 gonzalo-trenco/19c62ce08a135feacb800d70983797d2 to your computer and use it in GitHub Desktop.
Save gonzalo-trenco/19c62ce08a135feacb800d70983797d2 to your computer and use it in GitHub Desktop.
function to override FileReader API object type property
function setFileType(file, type) {
Object.defineProperties(file, {
'type': {
writable: true
}
});
file.type = type;
return file;
}
// Parsed File from FileReader API
var file = {
name: "2698bfcb870313a0c10df3e5af71666e.custom",
lastModified: 1486767600000,
lastModifiedDate: Sat Feb 11 2017 00:00:00 GMT+0100 (CET),
webkitRelativePath: "",
size: 63807,
type:"",
webkitRelativePath:""
};
file = setFileType(file, 'application/octet-stream')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment