save csv to server

good day, is there a way that instead of downloading the csv file from kintone, it will be save into another server?

Hello  Han,

What you are trying to do is that kintone data can be automatically saved at another server?
If so, here are the steps for this process.

  1. Execute API at another server to get the data from kintone.
  2. Once the data is retrieved from kintone to another server, download the retrieved data in CSV format at another server
  3. save the csv file at another server.

As another option, I think you can download the kintone data in CSV file at local directory, and transfer the data from the local PC to another server.

For your reference, at kintone, there is a feature that allows data to be downloaded in CSV format. Usually it might be good enough but sometimes you collect the data from another App or you can download the data retrieved from another service using kintone.proxy().

I would like to introduce you to this following coding that how you can download CSV file also. In this example below, the record with two fields(called “column1” and “column2”) are output, but by referring this sample, you might be able to output the data at kintone to local directory.

(function () {
     "use strict";
  
     // Record List event
     kintone.events.on('app.record.index.show', function(events) {      
         var $link = $('#download-csv');
         if ($link.length == 0) {
             // create the link at header
             var $header = $(kintone.app.getHeaderMenuSpaceElement());
             $link = $('<a id="download-csv" href="#">download with CSV</a>');
             $header.append($link);
         }
         
         // Escape
         var escapeStr = function(value) {
             return '"' + (value? value.replace(/"/g, '""'): '') + '"';
         };
         
         if ((window.URL || window.webkitURL).createObjectURL == null) {
             // not supported browser
             return;
         }
         
         // create CSV data
         var csv = [];
         var row = ['ID','column1','column2'];
         csv.push(row);
         for (var i = 0; i < events.records.length; i++ ) {
             var record = events.records[i];
             row = [];
             row.push(escapeStr(record['recordID'].value));
             row.push(escapeStr(record['column1'].value));
             row.push(escapeStr(record['column2'].value));
             csv.push(row);
         }
         
         // download with BOM
         var csvbuf = csv.map(function(e){return e.join(',')}).join('\r');
         
         var bom = new Uint8Array([0xEF, 0xBB, 0xBF]);
         var blob = new Blob([bom, csvbuf], { type: 'text/csv' });
         
         var url = (window.URL || window.webkitURL).createObjectURL(blob);
         
         var fileName = "download.csv";
         if (window.navigator.msSaveOrOpenBlob) {
             // for IE
             $link.unbind();
             $link.click(function() {
                 var retVal = window.navigator.msSaveOrOpenBlob(blob, fileName);
             });
         } else {
             $link.attr('download', fileName);
             $link.attr('href', url);
         }
     });
 })();

Hope it helps.

Thank you.

Junko