Ignore updates in a particular directory during deployment

Hello, I’m currently in the process of building an application that utilises the Netlify API (Node.js) in order to help users create and deploy sites. One issue I’m facing at the moment is finding a way to ignore the ‘images’ folder in the user’s website directory so it is not being monitored during deployment.

What I want to achieve is keep uploading images to the ‘images’ directory of the Netlify site, however once they are uploaded to Netlify and the site is deployed, I want to be able to delete the image files from my local storage. Currently, If I do that, the next time an update is made and the site is re-deployed, the API detects that the ‘images’ folder is now empty and deletes all the images on the Netlify site.

Is there a way to detach the ‘images’ folder so I can manually control it’s deployment? What would be an ideal solution is if every time the ‘images’ folder contains files in it, to deploy them, but when the ‘images’ folder is empty to ignore it and not delete the images on the Netlify site.

I tried experimenting with the netlify.toml file however I wasn’t able to find a solution.

Hi @samlar10 and welcome to our community! Sorry it’s taken so long to get back to you.

Our deploys are intended to be all or nothing - there is no concept of a folder to “carry over” - it’s “what you send is what we deploy”, when you deploy via API. You can, as we’ve done, implement caching in your implementation - something like “save images to special location X after build && copy them from X location during build”, to handle that workflow.

Note that every deploy method EXCEPT zipfiles will not have you “reuploading” unchanged content. I expect you’re using something like the digest file method (https://docs.netlify.com/api/get-started/#file-digest-method), where you send us a checksum of all files, and we send you back a list that you need to provide - which will not include any content already uploaded to a non-deleted site. I don’t know if saving time/bandwidth is a priority, but if so, we handle that for you, even if you still need to have the files present at deploy time.

You could alternatively make two sites and deploy the images on one, and link to the images site from the other site, which no longer has images, or even proxy to it using this feature: https://docs.netlify.com/routing/redirects/rewrites-proxies/#proxy-to-another-service (you can proxy to a second netlify site instead of a separate service).

If you build in our CI instead, you could absolutely design a build process that saves whatever you want to our cache, to be available later. I might use a build plugin to do this: https://app.netlify.com/teams/netlify/plugins?search=cache

I understand this isn’t your desire, but it will may others who might find this thread and be trying to solve the problem while building sites in our CI :slight_smile: