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 urls to media to be the urls directly to the source, instead of redirect from Raytha #87

Closed
apexdodge opened this issue Mar 6, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@apexdodge
Copy link
Contributor

Currently, when a file is uploaded, either via the Attachments field type, or if uploaded within a long text / wysiwyg field, the url that is generated is always something like /raytha/media-items/objectkey/abc.

The good

  • If storage moves to a new location, the urls will still work so long as the object keys remain the same.
  • In theory, can easily require users to be logged in / have some authorization by adding [Authorize] attribute on the controller, etc.

The bad

  • It adds request load on the server, for example, if you have a gallery list view with 25 images, that is 25 requests to the web server that need to be redirected (browser caching might reduce this but still).

Proposal:

We add an environment variable under storage that, if turned on, will output the URLs to directly to the source storage. It will default to off though.

@apexdodge apexdodge added the enhancement New feature or request label Mar 6, 2023
@apexdodge apexdodge added this to the v1.0.5 milestone Apr 8, 2023
@apexdodge
Copy link
Contributor Author

Decided to change the implementation here, simplified it, but I'm quite happy with the decision for now. This is now a choice for outputting the URL to the file via liquid filter.

  1. Added a new filter attachment_redirect_url liquid filter which outputs the URL of /raytha/media-items/objectkey/{{ Target.PublishedContent.attachment.Value }} which is the same behavior as the current existing filter raytha_attachment_url.

  2. Added a new filter attachment_public_url which will output the direct url to the blob on the file storage provider. A requirement of this method is that your bucket or container needs to have anonymous public-read access on the objects because it will not generate a presigned url or SaS url.

  3. raytha_attachment_url is now deprecated. Consumers should switch to attachment_redirect_url in their templates to preserve the same behavior. To be removed in v1.0.6.

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

No branches or pull requests

1 participant