Skip to main content

Upload files to Cloudflare R2

This page explains how to upload files to Cloudflare R2 with FluentCI.

Before you begin

The instructions on this page assume that you are familiar with Cloudflare R2. In addition:

  • Have your project ready, including the files you want to upload.
  • Have a Cloudflare account.
  • Have a Cloudflare R2 Bucket.
  • Have a Cloudflare R2 Access Key.
  • Have a Cloudflare R2 Secret Key.

Using the R2 Plugin

You can use FluentCI to upload files to Cloudflare R2 using the r2-sync plugin, no need to install AWS CLI on your machine, FluentCI will handle everything for you.

The following command can be used to upload files to Cloudflare R2:

# Make sure to set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
fluentci run --wasm r2-sync upload --endpoint-url https://$ACCOUNT_ID.r2.cloudflarestorage.com s3://$BUCKET_NAME

CI/CD pipeline integrations

The following examples show how to integrate FluentCI with popular CI providers to upload files to Cloudflare R2:

ci.yml
name: ci
on:
push:
branches:
- main
jobs:
tasks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Fluent CI
uses: fluentci-io/setup-fluentci@v5
- name: upload
run: fluentci run --wasm r2-sync upload --endpoint-url https://$ACCOUNT_ID.r2.cloudflarestorage.com s3://$BUCKET_NAME
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}