Upload file using ionic native or backend REST api


#1

Hi all…
I need to upload camera image to backend server.
Which one is better ??

  1. Using ionic native camera + file-transfer…or…
  2. Using ionic native camera + REST api file upload from backend service.
    Thanks in advance.

#2

Hmm, that really just depends on your comfort level.
I’m all for just letting the web handle most thigns and using a plugin when I need to. So I’d have to vote for the camera plugin + http.post


#3

Thks for reply @mhartington,

Already try for option no.2.
Using ionic native Camera and FileUpload REST api from Backendless service.
One of Request Header from backend was Content-Type:“multipart/form-data” and I’m using imageURI / FILE_URI from Camera and upload it to backend.
Could it be a problem ? Because my upload was successful and no error and return a fileURL but the image file was not save / available at backend file storage.
Please an advice.
Thanks in advance.


#4

For more information… here are my headers

**General**
Request URL:https://api.backendless.com/v1/files/profile/1466926162527.jpg
Request Method:POST
Status Code:200 OK
Remote Address:149.56.79.124:443

**Response Headers**
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Sun, 26 Jun 2016 07:27:28 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: file://
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH
Access-Control-Allow-Headers: Origin, application-id, application-type, Content-Type, secret-key, request, user-token
Content-Encoding: gzip
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache
Cache-Control: : no-store, no-cache, must-revalidate, private
Pragma: : no-cache

**Request Headers**
POST /v1/files/profile/1466926162527.jpg HTTP/1.1
Host: api.backendless.com
Connection: keep-alive
Content-Length: 95
application-type: REST
Origin: file://
User-Agent: Mozilla/5.0 (Linux; Android 5.0; SM-N900 Build/LRX21V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/51.0.2704.81 Mobile Safari/537.36
Content-Type: multipart/form-data
application-id: 06973966-D94F-5CED-FF60-60220932F300
secret-key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X-DevTools-Emulate-Network-Conditions-Client-Id: 59B8EB13-513A-4959-B05B-95ED4CD21B5D
user-token: 43688E4B-5616-215E-FFF5-84146990EB00
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.8
X-Requested-With: com.ionicframework.socity217267

**Here are the Response**
{"fileURL":"https://api.backendless.com/06973966-d94f-5ced-ff60-60220932f300/v1/files/profile/1466926162527.jpg"}