Uploaded file through restapi when downloaded - is not a valid file

  1. 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

Hi,
what URL do you use to download a file? An example of download URL can be found here.

Thanks Maxim for the reply. I manage my server and i have downloaded from the folder of the server where file is uploaded. The uploaded file is 37 kB while the file on server is 38 kB. I dont know whether this is the cause.
Please guide.

Please type the URL you’re using to download the file.
What exact error do you get on the client side: the code, the text?
Also are there any exception in server log?

Thank Maxim, the issue is solved. I have been uploading file using direct upload method given in documentation and still using the form data. In rest api call,
body = this.file
this line has solved the issue.
Thanks