Allow overriding the default file visibility set by FlysystemFS #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Hi everyone, here is a little PR with an addition we have made to the FS in some of our private projects. Allowing us to override the default Object Visibility for new files.
At this moment the Object Visibility for new files created in the cloud is directly tied with the 'HasUrls' option in the
craft\flysystem\base\FlysystemFs
classprotected function visibility(): string{ return $this->hasUrls ? Visibility::PUBLIC : Visibility::PRIVATE; }
However we have use cases where we have a private cloud bucket but we do want to set a URL for the files in our filesystem in Craft. This way we can redirect people who want to access a file from the bucket to a controller where we check authentication and then stream the file to the client. This way we can still use the normal getUrl method in our twig files even though there is no direct URL to the file in question.
At this moment you can already do this with the plugin however uploading a new file in the backend will throw a 500 error as the FileSystem will try and set the Object Visibility to 'Public' which will fail when the bucket is private only.
No hard feelings if this doesn't seem useful for other people :) Just thought it would be nice to share as we have chosen this route a few times.