-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add native copyObject
API support for R2 disks
#3834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Instead of letting the users hard code this via config, it's better to detect the type of disk in |
Your point about detecting the disk type in However, the challenge is that Cloudflare R2 provides an S3-compatible API, so users typically use the same S3 disk configuration and SDK for both S3 and R2. This makes it difficult to distinguish between them programmatically. Given this, how can we reliably detect whether the storage is S3 or R2? In my case, I’ve added a new disk named This leaves us with two options:
In my opinion, the first option is preferable because it provides a clearer and more flexible solution, which is why I chose it. |
If you have some better idea in mind, you are welcomed to guide me and i'll update it. @freekmurze |
Maybe instead of adding a global option in our config file, let's make it work by letting people adding a configuration option at the configured disk itself, so we can read there. A bit similar of how we ask people to ask to add dump configuration on the db connecting itself: https://spatie.be/docs/laravel-backup/v9/installation-and-setup#content-skipssl-in-mysqlmariadb-database-connection |
@freekmurze That's a good point. I'll update it. And thanks for the guidance. |
That looks much better 👍 Could you remove the unrelated styling changes to this PR only has the real changes for the functionality? |
@freekmurze Done. |
|
||
function callProtected(object $obj, string $method, array $args = []) | ||
{ | ||
$ref = new ReflectionClass($obj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could require-dev our own spatie/invade package to do this.
This PR adds optional support for native copyObject when using R2-compatible S3 disks.
force_server_copy
variable in disk configuration define is that R2 disk and usecopyObject
.This improves performance and avoids unnecessary file downloads/uploads.