I would like to upload csv file from client (Angular) and parse it on server (Java). That's how my java enpoint looks like:
@POST
@Path( "/csv-objects" )
@Consumes( MediaType.MULTIPART_FORM_DATA )
public Response getCsvObjects(
@FormDataParam( "file" ) InputStream aCsv,
@FormDataParam( "file" ) FormDataContentDisposition aCsvDetails
)
{
return Response.ok(csvImporter.getObjectsFromCsv( aCsv ) );
}
Looks exactly like example reffered here LINK
On the opposite client side:
public importFromCsv(file: File): Observable<any> {
const uploadedFile: FormData = new FormData();
uploadedFile.append( 'file', file, file.name);
return this.httpClient.post(`${this.DEFAULT_ENDPOINT}/csv-objects`, uploadedFile);
}
I have also tried use Blob:
public importFromCsv(file: File): Observable<any> {
const uploadedFile: FormData = new FormData();
uploadedFile.append( 'file', new Blob([file], {type: 'text/csv'}) );
return this.httpClient.post(`${this.DEFAULT_ENDPOINT}/csv-objects`, uploadedFile);
}
or add headers Content-Type: multipart/form-data but there is no result - always getting 415 Unsupported Media Type
What can be wrong?

