GregMc
Posts: 0
Joined: Wed Dec 03, 2014 12:46 am

How to retrieve file from database using server code

Hi,

I have uploaded a csv file to the pre-defined "Files" database collection. I need to retrieve the content of this file using a server code script and perform operations on its contents. I have read through the server code documentation and can successfully retrieve all the file content using an XHR GET request. This is what I have so far in the script (I have blanked out database ID and master key for security):

var XHRResponse = XHR.send("GET", "https://api.appery.io/rest/1/db/files", {
"headers": {
"X-Appery-Database-Id": "xxxx",
"X-Appery-Master-Key": "xxxx"
},
"parameters": {
"where": '{"Original File Name":"challenges_011515"}'
}
});
response.success(XHRResponse.body, "text/plain");
console.dir(XHRResponse);

But as far as I can tell this code only returns all the information in the columns of the Files collection, how do I retrieve the actual file or its content using server code script? Ultimately I have a 3rd party library I would like to use to parse the rows of csv data to JSON objects.

Thanks.

This is w

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

How to retrieve file from database using server code

Hello Greg,

We are working on it and will get back to you with the update.

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

How to retrieve file from database using server code

Hello,

You have wrong url. It should be like this: {database_url}/files/{database_id}/{file_name}
where file_name - file name column, not Original File Name

Return to “Issues”