Help with Laravel R2 Integration - "Header 'x-amz-checksum-crc32' Not Implemented"

Hi, I'm integrating Cloudflare R2 into a Laravel project using the league/flysystem-aws-s3-v3 adapter. However, when attempting to upload a file to R2 for testing, I encounter the following error:
League\Flysystem\UnableToWriteFile Unable to write file at location: example.txt.
Error executing "PutObject" on "https://psww-fss-storage.45748884cf5de2a3cff083c6eb2319b9.r2.cloudflarestorage.com/example.txt";
AWS HTTP error: Server error: `PUT https://psww-fss-storage.45748884cf5de2a3cff083c6eb2319b9.r2.cloudflarestorage.com/example.txt` resulted in a `501 Not Implemented` response:

NotImplemented (server): Header 'x-amz-checksum-crc32' with value 'AAAAAA==' not implemented.
My Current Configuration:
Here’s my R2 configuration in config/filesystems.php:
League\Flysystem\UnableToWriteFile Unable to write file at location: example.txt.
Error executing "PutObject" on "https://psww-fss-storage.45748884cf5de2a3cff083c6eb2319b9.r2.cloudflarestorage.com/example.txt";
AWS HTTP error: Server error: `PUT https://psww-fss-storage.45748884cf5de2a3cff083c6eb2319b9.r2.cloudflarestorage.com/example.txt` resulted in a `501 Not Implemented` response:

NotImplemented (server): Header 'x-amz-checksum-crc32' with value 'AAAAAA==' not implemented.
My Current Configuration:
Here’s my R2 configuration in config/filesystems.php:
'r2' => [
'driver' => 's3',
'key' => env('R2_ACCESS_KEY_ID'),
'secret' => env('R2_SECRET_ACCESS_KEY'),
'region' => 'auto',
'bucket' => env('R2_BUCKET'),
'url' => env('R2_URL'),
'endpoint' => env('R2_ENDPOINT'),
'use_path_style_endpoint' => env('R2_USE_PATH_STYLE_ENDPOINT', false),
'throw' => true,
],
'r2' => [
'driver' => 's3',
'key' => env('R2_ACCESS_KEY_ID'),
'secret' => env('R2_SECRET_ACCESS_KEY'),
'region' => 'auto',
'bucket' => env('R2_BUCKET'),
'url' => env('R2_URL'),
'endpoint' => env('R2_ENDPOINT'),
'use_path_style_endpoint' => env('R2_USE_PATH_STYLE_ENDPOINT', false),
'throw' => true,
],
I’m testing with this simple code:
$test = Storage::disk('r2')->put('example.txt', 'Hello World');
$test = Storage::disk('r2')->put('example.txt', 'Hello World');
Issue: The error indicates that the header x-amz-checksum-crc32 is not implemented. I suspect this might be due to the AWS SDK adding headers that R2 does not support. Question: Is there a way to configure the AWS SDK or Laravel Flysystem to disable this header? Has anyone else encountered this issue, and how did you resolve it? Thanks in advance for your help! 😊
1 Reply
harshil1712
harshil171223h ago
Hey, this is caused due to the recent change in the AWS SDKs. You can find a solution here: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-php/
Cloudflare Docs
aws-sdk-php · Cloudflare R2 docs
Example of how to configure aws-sdk-php to use R2.

Did you find this page helpful?