Skip to content
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

Allow overriding the default file visibility set by FlysystemFS #35

Closed
wants to merge 2 commits into from

Conversation

Numkil
Copy link
Contributor

@Numkil Numkil commented Aug 29, 2023

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 class

protected 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.

@Numkil
Copy link
Contributor Author

Numkil commented Oct 9, 2023

@brandonkelly

Would this be a change you would be interested to merge in this project? I would very much appreciate it if you gave this a look.

@timkelty
Copy link
Contributor

@Numkil Thanks! I made a couple tweaks on top of your commits, so I I'm going to close this PR in favor of: #37

@timkelty timkelty closed this Mar 20, 2024
@brandonkelly
Copy link
Member

Just tagged version 2.2.0 with this pulled in (via #37).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants