An uploader tool used to bulk upload image files from a local directory to Cloudflare's Images CDN product.
- The local directory is read, and a recursive JSON object is created based on the files and sub folders in the directory.
- The multi-level object is then converted to a flat list
- This local flat list is then compared to the flat list of the images in Firebase
- If the local images don't exist in Firebase, upload them. If Firebase contains images that aren't there locally, delete them. This in turn allows for renames, as a rename is simply a delete and upload with the new file name.
- The images are either uploaded or deleted from Cloudflare via the Cloudflare API.
- Firebase is then overwritten with the local images JSON object (called the manifest).
Steps to install and set up the image uploader locally.
- Clone the repository to your local machine.
- Run
npm installfrom the root of the project directory. - Copy the
.env_samplefile and rename it to.env- fill out the file accordingly. - Download your
serviceAccountKey.jsonfile from Firebase and add it to the root of the project.
Steps on how to use the image uploader
- Run
npm start "path\to\local\images"to begin the upload - Find that a
manifest.jsonfile is created in the root of the project containing all of the found images and maintaining the directory structure of the input path.