i want to send make a file upload, i am using angular in the front and spring boot in the backend.I have parameters to send in the request and the byte array in the body.but when i send this i got error 400.
this is my backend
@PostMapping(path=Urls.UPLOAD_FILE_IN_LIBELLE_GDA, produces = { MediaType.APPLICATION_JSON_VALUE})
public void uploadFileInLibelleGda(
@RequestParam String processus,
@RequestParam String level0Name,
@RequestParam String nomFichier,
@RequestParam String nomLibelle,
@RequestParam String anneeFolderName,
@RequestParam String semaineFolderName,
@RequestBody ByteArrayResource fichier) throws Exception {
uploadService.uploadFileInLibelleGda(racine, processus,level0Name,nomLibelle, anneeFolderName, semaineFolderName, nomFichier, fichier.getByteArray());
}
and this is my frontend
public uploadFiles(
nomFichier: string,
nomLibelle: string,
processus: string,
level0Name: string,
semaineFolderName: string,
anneeFolderName: string,
byte: Blob
): Observable<any> {
let params = new HttpParams();
params.append('level0Name', level0Name);
params.append('processus', processus);
params.append('nomLibelle', nomLibelle);
params.append('anneeFolderName', anneeFolderName);
params.append('semaineFolderName', semaineFolderName);
params.append('nomFichier', nomFichier);
return this.httpClient.post(this.urlUploadFile, byte, {
'params': params
});
}