- I have uploaded an image file through restapi add-on using direct upload method provided in documentation from angular frontend. The file is uploaded without any issue. This is code
this.file = fileChangeEvent.target.files[0];
const formData = new FormData();
formData.append("image", this.file, this.file.name);
console.log(this.file.name);
const fileurl = 'https://ddddd.cloudjiffy.net/rest/files?name=' + this.file.name;
const body = formData;
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'image/jpeg',
'Authorization':'Bearer ' + this.jwt,
'Accept':'*/*'
})
};
this.httpClient.post(fileurl, body, httpOptions).subscribe(data => {
console.log(data);
this.consumerForm.controls['image'].setValue(data['fileRef']);
console.log('uploaded');
}, async (err: Response) =>{
const toast = await this.toastController.create({
message: 'Could not be uploaded, Try Again',
duration: 3000
});
toast.present();
});
but when this file is downloaded from server, it says that it is not a valid file.
Please advice.
Thanks