mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Add function for reading file as array buffer
This commit is contained in:
parent
8910bf0dbd
commit
fefc635e25
@ -14,6 +14,14 @@
|
|||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
readFileAsArrayBuffer : function (file, callback) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.addEventListener("loadend", function() {
|
||||||
|
callback(reader.result);
|
||||||
|
});
|
||||||
|
reader.readAsArrayBuffer(file);
|
||||||
|
},
|
||||||
|
|
||||||
readImageFile : function (file, callback) {
|
readImageFile : function (file, callback) {
|
||||||
ns.FileUtils.readFile(file, function (content) {
|
ns.FileUtils.readFile(file, function (content) {
|
||||||
var image = new Image();
|
var image = new Image();
|
||||||
@ -28,7 +36,7 @@
|
|||||||
saveAs(content, filename);
|
saveAs(content, filename);
|
||||||
} else {
|
} else {
|
||||||
var downloadLink = document.createElement('a');
|
var downloadLink = document.createElement('a');
|
||||||
content = window.URL.createObjectURL(content);
|
content = window.URL.createObjectURL(new Blob([content]));
|
||||||
downloadLink.setAttribute('href', content);
|
downloadLink.setAttribute('href', content);
|
||||||
downloadLink.setAttribute('download', filename);
|
downloadLink.setAttribute('download', filename);
|
||||||
document.body.appendChild(downloadLink);
|
document.body.appendChild(downloadLink);
|
||||||
|
Loading…
Reference in New Issue
Block a user