Page 1 of 2

send image from gallery

Posted: Tue Jun 03, 2014 11:53 am
by Dirk Gissing

Hello,

In my app users have the option to upload a picture from their phone gallery to the app. This works and the image is shown in an element called "upload_image". Now I want the URL of this uploaded image to be sent with the other data. How do I retrieve the URL of the uploaded image?

I've tried "alert(Appery('image_upload').attr('src'));" but this shows a HUGE alert with the raw image source code, not the URL.

How do I do this?

Thank you!


send image from gallery

Posted: Tue Jun 03, 2014 4:20 pm
by Kateryna Grynko

Hi Dirk,

You should pass a direct link to a file: http://devcenter.appery.io/documentat...

Uploade your image to Database beforehand: https://getsatisfaction.com/apperyio/...


send image from gallery

Posted: Wed Jun 04, 2014 12:34 pm
by Dirk Gissing

Thank you Katya, I will try this and update afterwords!


send image from gallery

Posted: Mon Jun 09, 2014 1:27 pm
by Dirk Gissing

I've tried the solution you provided "pass a direct link to a file". But I can't upload the base64 to the files collection. I keep getting "unauthorized" or "Cannot consume content type".

What should I do


send image from gallery

Posted: Mon Jun 09, 2014 6:09 pm
by Evgene Karachevtsev

Hello Dirk,

You get unauthorized because you don't send session token to service.
You get "Cannot consume content type" probably because you send wrong header "Content-Type". For image you should send one of these:
http://en.wikipedia.org/wiki/Internet...


send image from gallery

Posted: Mon Jun 09, 2014 8:20 pm
by Dirk Gissing

I don't send session token because I don't have session token. Users don't have to login to upload a picture. I'm making a damage form for users so that they can send details of a damage and a picture. The app can be used without having to login.


send image from gallery

Posted: Mon Jun 09, 2014 8:35 pm
by Dirk Gissing

And about the "cannot consume content type": I only get that error when I try to use the files_upload_service. That service does not have the "Content-Type" header, and when I manually add that header parameter, it still doesn't work. In the other service "files_create_service" there is a parameter called "Content-Type" but over there I get the error of the session token.


send image from gallery

Posted: Mon Jun 09, 2014 9:31 pm
by Dirk Gissing

I can use the "files._create_service" now in the test environment and it works. A file is indeed uploaded, but when I try to download the jpeg file, it can't be opened. It's a corrupted JPEG file. The base64 data I retrieved from the photocamera, so it should be about right.

What is the problem here?


send image from gallery

Posted: Tue Jun 10, 2014 3:13 pm
by Evgene Karachevtsev

Hello Dirk,

The base64 data is not jpeg file so you have message "it's a corrupted JPEG file"


send image from gallery

Posted: Tue Jun 10, 2014 4:58 pm
by Dirk Gissing

So how do I save a picture taken from the photogallery of the user to the files collection then??