Patrick Tan6809353
Posts: 0
Joined: Tue Apr 15, 2014 7:57 am

extracting csv file without providing login to end client

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

extracting csv file without providing login to end client

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...

Neel Suresh Sus
Posts: 0
Joined: Fri Jun 07, 2013 7:48 am

extracting csv file without providing login to end client

@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));
};

Return to “Issues”