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 links without public URLs #17

Open
CustomCodeIT opened this issue Apr 11, 2024 · 3 comments
Open

Allow links without public URLs #17

CustomCodeIT opened this issue Apr 11, 2024 · 3 comments
Labels
feature request New feature or request

Comments

@CustomCodeIT
Copy link

CustomCodeIT commented Apr 11, 2024

Hi there,

Are you able to confirm if generating links for assets without a public URL is supported?

I see a few mentions of it being supported in previous issues but it still doesn't seem to be the case. I can see the following code here that seems to confirm it not being supported:

image

It is a valid and common use case to have files that shouldn't have public URLs but still need to be served to a client. In my case I am using S3 file storage and need to protect downloads from unauthenticated users, leeching/hotlinking, search engine indexing etc.

I haven't done enough investigation to fully test a fix, and there might be much better ways to handle this, but could we use Craft's native "getCopyOfFile()" method to download a copy of this file to a temp directory before serving it to the client, thus removing the need to have public URLs? I tested this and it seems to work.

I would say there's potential downsides to this solution:

  • You're essentially downloading files twice
  • Large files might be slow
  • Might impact disk space on high-traffic sites downloading into temp
  • The method mentioned assigns a unique filename every time so that's not ideal and might need a workaround
  • Probably many more I haven't thought of

Maybe you or someone else has a way better idea for handling this use case?

Other plugins (like LinkVault) seem to handle it in this way but unfortunately it has been abandoned so I'm trying to get this plugin to work for my specific needs.

Craft: 4.8.9
DigitalDownload: 2.3.0

@CustomCodeIT CustomCodeIT changed the title Allow links without public URL on filesystem Allow links without public URLs Apr 11, 2024
@lindseydiloreto
Copy link
Contributor

Thanks for inquiring! The short answer is "no", Digital Download does not currently support cloud assets without a public URL. It is a technical limitation of how the downloads work, unfortunately.

However, I hadn't seen the getCopyOfFile solution in Link Vault. That seems like a clever workaround, even if it comes with some drawbacks. Craft has evolved a lot over the years, it's possible that there are some modern solutions to these older problems.

Thanks for the tip. I'll take a deeper dive into our options, and let you know what I find. 👍

@lindseydiloreto
Copy link
Contributor

Shoot, didn't mean to close that. 😄

@lindseydiloreto lindseydiloreto added the feature request New feature or request label Apr 13, 2024
@CustomCodeIT
Copy link
Author

Thanks for your help. Let me know if there's anything you need from me, happy to help where I can

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

No branches or pull requests

2 participants