Is there a way to automate adding files to gallery folder? sftp access from external node.js app possibilities

Does anyone have suggestions on ways to automatically add files to a folder? I need to connect an external data source, so i’d like to build a node.js app to process the data and send it to the Treepl file system. Ideally, I would like to create custom module items with the api to set the data on each item, but that doesn’t seem to be available soon enough, so I need to figure out another way to do this. Any help would be great. Thanks.

Hi @g.davis

You can fairly easy use the file API to display images from a folder :slight_smile:

Something like this


{% component resource: "File System", folder: "/assets/imagefolder", collectionVariable: "images", type: "api" %}


{% for item in images.items %}
        <div>
            <a href="{{item.url}}" target="_blank">
                 <img src="{{item.Url}}?width=140" style="max-width: 100%;" alt="">
            </a>
        </div>
{% endfor %}

Thank you, yes I want to use this, but first I need to get the data to the folder from an outside database. I need to automate that process, so I need to build an app that pulls from the original database periodically and adds it to the specified folder. It’s a process that has to run on a schedule. I’m currently working with it by pulling the data when the page loads, but that slows it down. Do you know a way to get this done? Thank you for any ideas on this.

Sounds really cool. The clients that use this of ours bulk upload the files through the backend.

The original database you need to pull the data from is based on what? :slight_smile:
Sounds interesting what you are doing today with pulling the data on page load - do you want to show that here? :slight_smile:

The company is a pet adoption shelter that exports the data from their database (as a CSV file) with all the data on the pets available for adoption. I process this using PapaParse when the page loads to populate a template and show the image, name, breed of dog, age, etc.

At minimum, I’m going to see if they can have the CSV file drop directly on the file system periodically (via sFTP), then use that info to build the page. It would cut down on time transfer of the CSV file if it was on the server when building the page. But, it would be good to have a node.js app process the CSV file and put the data into different folders on the Treepl file system.

Is there any way that you can export the data via a JSON endpoint rather than a CSV file? This way you can just import it to Treepl using this: JSON (parsing via Liquid)