dibe84
Posts: 0
Joined: Fri Dec 06, 2013 11:20 am

Using File Create Service (without JS)

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Using File Create Service (without JS)

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":
}

dibe84
Posts: 0
Joined: Fri Dec 06, 2013 11:20 am

Using File Create Service (without JS)

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Using File Create Service (without JS)

Gabriele,

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

dibe84
Posts: 0
Joined: Fri Dec 06, 2013 11:20 am

Using File Create Service (without JS)

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Using File Create Service (without JS)

Hello,

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

dibe84
Posts: 0
Joined: Fri Dec 06, 2013 11:20 am

Using File Create Service (without JS)

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.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Using File Create Service (without JS)

Hello Gabriele,

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

Return to “Issues”