Angular 2 error while executing file upload

0

I have a system that uploads files from an angular application 2 to a java system and saves it to a sql server database. In the angular application 2 and in the system in java I am saving in String format, and in sql server database in the formed CLOB or VARCHAR (MAX). The problem occurs because I need the system to save files up to 5 MB. As far as I know the CLOB allows to save contents of up to 2 GB, which would not be a problem. Well what happens is that every time I do the put, or post in a file larger than a few KB, it generates the following error:

documents-list.component.ts

fileChange(event:any){letfileList:any=event.target.files;varreader:any=newFileReader();reader.onload=(readerEvt:any)=>{varbinaryString=readerEvt.target.result;this.documentoSelecionado.conteudo=btoa(binaryString);this.listaArquivos.set(this.documentoSelecionado.codigo,this.documentoSelecionado);};reader.readAsBinaryString(fileList[0]);}

documents.service.ts

update(documento:Documentos):Observable<Documentos>{letbody=JSON.stringify(documento);if(!documento.codigo){returnthis.http.post(this.url,body).map(response=><Documentos>response.json()).catch(this.handleError);}else{returnthis.http.put(this.url+"/" + documento.codigo , body)
        .map(response => <Documentos> response.json())
        .catch(this.handleError);
    }
}

documents.ts

  export class Documentos {
public codigo: number;
public codigoPessoa: number;
public tipo: number;
public conteudo: string;
public dataInsercao: string;
public extinto: boolean;
public extensao: number;

}

The field public content: string; is the field that contains the file that will be passed to the server to save to the database, however when running

   else{
      return this.http.put(this.url + "/" + documento.codigo , body)
        .map(response => <Documentos> response.json())
        .catch(this.handleError);
    }

This code, it always falls into the cath and never passes to the server, if the file is larger than 100KB. If the file is smaller it passes. I would like to know the reason for this error and a possible solution.

    
asked by anonymous 26.01.2018 / 12:17

0 answers