This is a simple script that retrieves the URLs of all objects (no empty folders) in a specified R2 bucket and saves them to a JSON. The script uses the Cloudflare API to access the R2 bucket and requires an API credentials and that API needs to have appropriate read permissions.
- NodeJS 18+
- A Cloudflare account with an R2 bucket
- Clone the repository:
git clone
- Navigate to the project directory:
cd simple-r2-bucket-urls-getter - Install the dependencies:
npm install
- Create a
.envfile in the root of the project and add your Cloudflare information as the ".env.example" file. - Run the script:
npm start
- All the URLs of the objects in the specified R2 bucket will be saved by default in the
saveFilesfolder under project directory with the following name{current_date}.json.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a pull request or open an issue if you have any suggestions or improvements.