Page 1 of 1

Using File Create Service (without JS)

Posted: Thu Oct 23, 2014 8:30 am
by dibe84

Hello Support,

I have two questions:

1) Long ago i set up the file-creation service using the "Drag&Drop" interface (without coding in Javascript), now i only found only the tutorial to use it with JS (or the multiple uploader helper). How can I set the parameters to use the D&D? (I remember there was "encode" to set with base64 and other parameters).

2) Once I called it with the D&D is it possible to get the id of the created file with the response using the service? (in javascript I get it using "data.filename").

Thanks a lot for your help!

Have a good day.

Gabriele


Using File Create Service (without JS)

Posted: Thu Oct 23, 2014 9:47 am
by Evgene Karachevtsev

Hello Gabriele,

Yes. The old API is working, nothing has not changed.

To upload a file, send a POST request according to the URL:

curl-X POST \
-H "X-Appery-Database-Id: " \
-H "X-Appery-Session-Token: " \
-H "Content-Type: " \
-d "" \
https://api.appery.io/rest/1/db/files/

where: is Appery DB user's session token;
is the database unique identifier;
the is the name of file in DB;
is the MIME content type;
is the contents of the file;

Server returns HTTP 201 Created status and JSON object response (with "Location:" header):
{
"filename":,
"fileurl":
}


Using File Create Service (without JS)

Posted: Thu Oct 23, 2014 11:34 am
by dibe84

Thank you very much Evgene!
I just tried and it worked fine! I don't know what I did wrong yesterday evening because I think to have done the same thing.

Maybe there was some problems in the servers yesterday? Because many times I received errors randomly!

Thanks again!

Gabriele


Using File Create Service (without JS)

Posted: Thu Oct 23, 2014 11:44 am
by Evgene Karachevtsev

Gabriele,

As far as I know there weren't any issues with the server, but I'm glad it works for you now!


Using File Create Service (without JS)

Posted: Fri Oct 24, 2014 6:04 pm
by dibe84

Thank you Evgene.
I have another question: I'm struggling with the upload of an image. Which is the correct mapping always trying to avoid JS? I tried to drag from the attribute "asset" of the image compoenent to the "body.data" of the request of file_create_service. it works but the image is not a real image in the DB, it's just a base64 that, if downlaoded, doens't show the relative image.
So I used the function dataURItoBlob but the result in the body of the DB is just "type=image%2Fjpeg&size=19148".

Any idea?

Thanks again. Gabriele


Using File Create Service (without JS)

Posted: Sat Oct 25, 2014 5:59 pm
by Alena Prykhodko

Hello,

General idea is as in tutorial http://devcenter.appery.io/tutorials/...
Please read it and let us know if it helps.


Using File Create Service (without JS)

Posted: Mon Oct 27, 2014 10:36 am
by dibe84

Hi Alena,

Thanks a lot for the answer.
I've seen your link but I think it's dealing still with a base64 string (putting it into a custom field into a collection). What I'd like to do is to upload a blob into the "files" DB (no collection). I did it with JS but I'd like to do with the interface.


Using File Create Service (without JS)

Posted: Tue Oct 28, 2014 5:47 pm
by Evgene Karachevtsev

Hello Gabriele,

Could you please give js code which is working for you and screenshots of what you do with mapping?