Page 1 of 1

extracting csv file without providing login to end client

Posted: Tue Apr 15, 2014 3:34 pm
by Patrick Tan6809353

Hi,

I will like to develop an app using appery.io database. But i do not want to provide the client an access to login and access database. How do i achieve this? Do i have any option to allow user in accessing the database or best an exported csv? Or how do i ftp in, such as the path to the extracted data then i could probably build an external app to achieve this.

Cheers,
Pat


extracting csv file without providing login to end client

Posted: Tue Apr 15, 2014 6:08 pm
by Maryna Brodina

Hello!

To store data for common use you can use files table http://docs.appery.io/documentation/b.... For now there is no REST API to export data in CSV format, it can be done manually only http://docs.appery.io/documentation/b...


extracting csv file without providing login to end client

Posted: Fri Apr 03, 2015 4:11 am
by Neel Suresh Sus

@Patrick, this code makes it very easy to trigger a CSV download from a JSON array. Originally from Stackoverflow (http://stackoverflow.com/a/4130939/317) , I mod-ed it to be easier to use as needed (without button styles to trigger it)

function JSON2CSV(objArray, blnGetLabels) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;

Code: Select all

 var str = ''; 
 var line = ''; 

 if (blnGetLabels) { 
     var head = array[0]; 
     if ($("#quote").is(':checked')) { 
         for (var index in array[0]) { 
             var value = index + ""; 
             line += '"' + value.replace(/"/g, '""') + '",'; 
         } 
     } else { 
         for (var index in array[0]) { 
             line += index + ','; 
         } 
     } 

     line = line.slice(0, -1); 
     str += line + '\r\n'; 
 } 

 for (var i = 0; i < array.length; i++) { 
     var line = ''; 

     if ($("#quote").is(':checked')) { 
         for (var index in array[i]) { 
             var value = array[i][index] + ""; 
             line += '"' + value.replace(/"/g, '""') + '",'; 
         } 
     } else { 
         for (var index in array[i]) { 
             line += array[i][index] + ','; 
         } 
     } 

     line = line.slice(0, -1); 
     str += line + '\r\n'; 
 } 
 return str; 

}

function DownloadCSV(objArray, blnGetLabels) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var csv = JSON2CSV(array, blnGetLabels);
window.open("data:text/csv;charset=utf-8," + escape(csv));
};