Export and SFTP Custom Table Data

Dan Copping asked on June 10, 2020 03:08

Hi,

I have a form that saves to a Custom Table. I need to take the daily form submissions, save them to a csv and transmit that file to an SFTP location. Can you suggest the best way to tackle this in Kentico?

I am thinking I would create a Scheduled Task (as per https://docs.kentico.com/k12/configuring-kentico/scheduling-tasks/scheduling-custom-tasks) but I'm not sure how best to retrieve and transmit the data.

When looking at the data of the custom table via the administration interface, I see I have the option of an 'advanced export' which allows me to export the data to csv and set a query (so as to get only those entries from the last 24 hours). Are the API's used for this functionality publicly available? i.e. can I call this from my Scheduled Task? Or will I need to write my own custom code export the data and write it to csv?

Also, I expect I'll need to write custom code to transmit the file via SFTP... but if there are any Kentico API's that can help, please let me know.

Thanks in advance

Dan

Correct Answer

Dmitry Bastron answered on June 10, 2020 10:03

Hi Dan,

There are no public CSV and FTP APIs available in Kentico as far as I'm aware. But this is fine because these implementations can be easily found in Nuget. These are very good examples of using a package manager instead of relying on CMS. For CSV read/write operations we typically use CsvHelper and for FTP - FluentFtp.

And you are right, using a Scheduled Task for this would be a good practice.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dan Copping answered on June 25, 2020 09:28

Thanks Dmitry!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.