PHPackages                             rootscratch/cloudstorage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. rootscratch/cloudstorage

ActiveLibrary[File &amp; Storage](/categories/file-storage)

rootscratch/cloudstorage
========================

Cloudflare R2 Storage w/ aws-sdk-php

v1.0.1(1y ago)29MITPHP

Since Feb 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/jaycee0610/CF-R2-Storage-PHP)[ Packagist](https://packagist.org/packages/rootscratch/cloudstorage)[ RSS](/packages/rootscratch-cloudstorage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

[![CF R2 Storage](https://github.com/jaycee0610/CF-R2-Storage-PHP/raw/main/image.png?raw=true)](https://github.com/jaycee0610/CF-R2-Storage-PHP/blob/main/image.png?raw=true)

Cloudflare R2 Storage PHP
=========================

[](#cloudflare-r2-storage-php)

This project allows users to upload/delete files to Cloudflare R2 storage using PHP and AWS SDK. It supports image, video, and document uploads with flexible validation.

-

Features
--------

[](#features)

- Upload files to Cloudflare R2
- Supports multiple categories (image, video, docs, or a single file type)
- Delete files from Cloudflare R2
- Uses AWS S3 SDK for managing R2 storage
- Prevents invalid file uploads
- **File size limit:** Default is 200MB (can be customized)

Deployment
----------

[](#deployment)

To deploy this via cloning this URL

```
git clone https://github.com/jaycee0610/CF-R2-Storage-PHP.git
cd cloudflare-r2-upload
composer require aws/aws-sdk-php
```

Or Via Composer Package

```
composer require rootscratch/cloudstorage
```

Usage/Examples
--------------

[](#usageexamples)

Add your Cloudflare R2 credentials:

- Using Composer Package

```
require_once __DIR__ . '../vendor/autoload.php';
use Rootscratch\Cloudstorage\Configuration;

// Set configuration values
Configuration::setEndpoint("https://your_end_point.r2.cloudflarestorage.com");
Configuration::setBucketName("bucket_name");
Configuration::setAccessKey("access_key");
Configuration::setSecretKey("secrey_key");
new Configuration();
```

### Upload a File

[](#upload-a-file)

```
use Rootscratch\Cloudstorage\UploadFile;
$cloud_upload = new UploadFile();
$upload_file = $cloud_upload->uploadFile($_FILES['test'], null, null);

echo json_encode($upload_file, JSON_PRETTY_PRINT);
```

### ✅ Success Response

[](#-success-response)

```
{
   "status": "success",
   "message": "File uploaded successfully.",
   "file_name": "randfilename.png",
   "mime_type": "image\/png"
}
```

### ❌ Error Response

[](#-error-response)

```
{ "status": "error", "message": "Unsupported file type." }
```

### Delete a File

[](#delete-a-file)

To delete a file, use:

```
use Rootscratch\Cloudstorage\DeleteFile;
$cloud_delete = new DeleteFile();
$delete_file = $cloud_delete->deleteFile('filename.png', null);

echo json_encode($delete_file, JSON_PRETTY_PRINT);
```

### ✅ Response

[](#-response)

```
{ "status": "success", "message": "File deleted successfully.", "file_name": "filename.png" }
```

### Valid File Categories

[](#valid-file-categories)

CategoryAllowed Formats`image`jpg, jpeg, png, gif, webp, svg`video`mp4, mov, avi, mkv`docs`pdf, docx, xlsx, txt`archives`zip, rar`database`sqlSpecific File `pdf`pdf`null`All### File Size Limit

[](#file-size-limit)

- The default file size limit is **200MB**.
- You can customize the size limit by passing the `$sizeLimit` parameter (in bytes) to the `uploadFile` method.

Example:

```
$cloud_upload = new UploadFile();
$upload_file = $cloud_upload->uploadFile($_FILES['test'], null, null, 50); // 50MB limit
```

### Base64Image to File

[](#base64image-to-file)

```
use Rootscratch\Cloudstorage\UploadFile;

$cloud_upload = new UploadFile();
$base64_image = 'data:image/png;base64,.';
$convert = $cloud_upload->base64Image($base64_image, 'filename.png');
$upload = $cloud_upload->uploadFile($convert, null, null);

echo json_encode($upload, JSON_PRETTY_PRINT);
```

### Cloudflare R2 Returning 403?

[](#cloudflare-r2-returning-403)

- Go to **Cloudflare Dashboard** → **R2 Storage** → **Permissions**
- Enable **Public Read Access** for the bucket.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance44

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

456d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/96e7723302f2828740841377232dddee236a773b0873fbe7a3a90aed929e6de5?d=identicon)[jaycee0610](/maintainers/jaycee0610)

---

Top Contributors

[![jaycee0610](https://avatars.githubusercontent.com/u/120337618?v=4)](https://github.com/jaycee0610 "jaycee0610 (16 commits)")

---

Tags

aws-sdkbucketcf-phpcloud-storagecloudflare-r2cloudflare-r2-apicloudflare-r2-phpr2-phprootscratch

### Embed Badge

![Health badge](/badges/rootscratch-cloudstorage/health.svg)

```
[![Health](https://phpackages.com/badges/rootscratch-cloudstorage/health.svg)](https://phpackages.com/packages/rootscratch-cloudstorage)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[humanmade/s3-uploads

WordPress plugin to store uploads on S3

2.1k2.4M9](/packages/humanmade-s3-uploads)[aws/aws-sdk-php-resources

A resource-oriented API for interacting with AWS services

1381.8M10](/packages/aws-aws-sdk-php-resources)[aws/aws-sdk-php-zf2

Zend Framework 2 Module that allows easy integration the AWS SDK for PHP

104997.5k5](/packages/aws-aws-sdk-php-zf2)[frostealth/yii2-aws-s3

An Amazon S3 component for Yii2

90698.9k5](/packages/frostealth-yii2-aws-s3)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
