Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
Upload large file by chunks using File reader using Angular

I am trying to upload files and the current code supports file size upto 100MB and if the size of the file increases getting out of Memory screen in browser

private ProcessReadFile(file:File){
   return new Promise<void>(resolve=>{
        const reader= new FileReader();
        let content:any;
        reader.onloadend=()=>{
                     content=reader.result;
                     var fileContent=content.split('base64,')[1];
                    this.fileUpload.push({
                       Filecontent:fileContent;
                       FileType:file.Type
                     });
                 resolve;
         };
     reader.readAsDataUrl(file);
     });
  }

Can some one please suggest/help me to improve below method upload large data files.

I tried to slice large files into chunks and append while converting to base64 string but its not working and getting hanged even for 30 MB file.

Please let me know whats the error and correction required.

 private ProcessReadFile(start,file){
       return new Promise<void>(resolve=>{
            
            const reader= new FileReader();
            var slice_size=10000*1024;
            var next_slice=start+slice_size+1;
            var blob=file.slice(start,next_slice);
            let content:any='';
            reader.onloadend=()=>{
                 if(reader.readyState!==FileReader.Done)
                 { 
                   return;
                 }
                 content=reader.result;
                let base64Split=content.split('base64,')[1];
                let resultString='';
                 resultString=this.base64String+base64Split.toString();
                this.base64String=resultString;
                if(next_slice<file.size)
                {
                  this.ProcessReadFile(next_slice,file);
                }   
                else
                {
                   this.fileUpload.push({
                           Filecontent:fileContent;
                           FileType:file.Type
                         });
                     resolve;
                  
                }
                         
                      
             };
         reader.readAsDataUrl(file);
         });
      }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda