File transfer / upload image from device to RESTful API

i wont upload an camera image to an RESTful Api. Api works create with other solutions.

So i used this tutorial:

https://devdactic.com/ionic-2-images/#disqus_thread

Api return Httpcode 400 Bad Request. The serverlog from sympfony with fos-restbundle gets:

Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: “Invalid json message received” at /…/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/BodyListener.php line 107

The Image is showing correctly. Path an names are correct, only the upload is faulty

It is possible to upload with @ionic-native/transfer to an json api?

 let options: FileUploadOptions = {
      fileKey: 'file',
      fileName: 'tmpTestfile.jpg',
      chunkedMode: false,
      mimeType: "multipart/form-data",
      headers:  {
        'Content-Type': 'application/json',
        'Auth': this.localData.getApiKey()
      }
    };

    const fileTransfer: TransferObject = this.transfer.create();
    // Use the FileTransfer to upload the image
    return fileTransfer.upload(imageData, '/api/image/', options)
1 Like

Hi,

Are you found a solution ? I have the same problem…

By,