Guest User

saveFileJS(f)

a guest
Aug 6th, 2023
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  async function saveFileJS(f) {
  2.  
  3.       console.log("arquivo: " + f);
  4.  
  5.       const file = f.files[0];
  6.       const fr = new FileReader();
  7.       var retorno = ""; //variavĂ©l para receber o retorno do obj
  8.  
  9.       fr.onload = function(e) {
  10.         const obj = {
  11.           filename: file.name,
  12.           mimeType: file.type,
  13.           bytes: [...new Int8Array(e.target.result)]
  14.         };
  15.         console.log("file: " + obj);
  16.         console.log("nome do arquivo: " + obj.filename);
  17.         //google.script.run.withSuccessHandler(e => console.log(e)).saveFile(obj,destino);
  18.        
  19.         retorno = obj; // determina o retorno como o obj
  20.        
  21.       };
  22.  
  23.       fr.readAsArrayBuffer(file);
  24.  
  25.       console.log("objeto = " + retorno);
  26.  
  27.       return retorno; //retorna obj
  28.  
  29.   }
Advertisement
Add Comment
Please, Sign In to add comment