R2: Calling `listObjectsV2` will fail with an HTTP 501 NotImplemented

For Workers & Pages, what is the name of the domain?

https://00114da7284cd3f18f0828080a2c9065.eu.r2.cloudflarestorage.com/?list-type=2&prefix=

What is the error number?

HTTP 501

What is the error message?

<?xml version="1.0" encoding="UTF-8"?>NotImplementedListBuckets search parameter list-type (truncated...) NotImplemented (server): ListBuckets search parameter list-type not implemented - <?xml version="1.0" encoding="UTF-8"?>NotImplementedListBuckets sea rch parameter list-type not implemented

What is the issue or error you’re encountering

Listing files in R2 via listObjectsV2 (S3 ListBuckets) fails with HTTP 501 NotImplemented using official AWS PHP SDK

What steps have you taken to resolve the issue?

  • Searched through the docs
  • Asked on Discord (no answer)
  • Tried to use League’s Flysystem (File Storage Abstraction for PHP - Flysystem), which uses the official AWS PHP SDK, but it’ll run into the same issues
  • Checked the S3 Compatibility API docs, which claims it is fully compatible

What are the steps to reproduce the issue?

  • Follow the official docs (aws-sdk-php · Cloudflare R2 docs)
  • You’ll need to update the S3 Client configuration with the following options, as you’d otherwise get an HTTP 404 or HTTP 401
"use_path_style_endpoint" => true,
"bucket_endpoint" => true,
"request_checksum_calculation" => "when_required",
"response_checksum_validation" => "when_required",
  • Execute the script and see it fail immediately when calling ->listObjectsV2()

I’ve created a dedicated reproducer to showcase the issue at GitHub - keichinger/cloudflare-r2-listObjectsV2-reproducer

It is in fact the code from the docs (with slight naming convention adjustments, since snake_case isn’t the norm in PHP :)) and the necessary composer-setup.

Please note that this reproducer is currently configured to require PHP 8.3 — it may also work if you change the php-entry within the composer.json to a lower version, however I haven’t tested that.