I get from the server an object that should represent a file, and it looks like this:
name: "סריקה0252.pdf",
url: "https:XYZ/ABC/1/סריקה0252_28-05-2019_11:24:40.pdf"
Now, I want to convert it to a file of JavaScript ,
Is it possible to do so?
I get from the server an object that should represent a file, and it looks like this:
name: "סריקה0252.pdf",
url: "https:XYZ/ABC/1/סריקה0252_28-05-2019_11:24:40.pdf"
Now, I want to convert it to a file of JavaScript ,
Is it possible to do so?
function urlToBlob(url){
return new Promise((resolve,reject)=>{
var xhr = new XMLHttpRequest();
xhr.open( "GET", url, true );
xhr.responseType = "blob";
xhr.onload = function( e ) {
resolve(this.response)
};
xhr.onerror = function( error ){
reject(error)
}
xhr.send();
})
}
let fileUrl = "https:XYZ/ABC/1/סריקה0252_28-05-2019_11:24:40.pdf"
urlToBlob(fileUrl).then(function(blob){
console.log(blob)
// you will get blob object of that file here
})
Here is the function to convert it. this will load the file first to the local. once it will be loaded, it will return blob object as return type is defined as a blob.
jsto parse this? or you want an actual filemyfile.js? if you want an actual file you would need a server sided language.