How to serve files on s3 just for logged in user

I’m doing a wp multisite install whre a user will upload files which will be hosted on S3 or DO storage block.

How should I go about it, so the files (ex image or pdf) loads for a logged in user and the direct s3 link can’t be accessed directly by anyone else?

This doesn’t seem like it involves the Roots stack: If you’re controlling the permissions on S3 urls, that validation would have to happen on the S3 servers. I would guess that this would entail setting some kind of per-object permissions on S3 when files are uploaded, but that’s just a guess—and it seems outside the scope of these forums. Is there something about this issue that you feel makes it Roots-specific?

Oh sorry about that, I just thought someone may know a solution for this and extend the trellis/do block storage article you have

https://roots.io/guides/using-digitalocean-block-storage-with-trellis/

Oh, I thought you were just talking about pushing content to S3. With local mount points you probably could do some interesting permissions stuff. @ben wrote that article so he might have a little more insight. My guess would be you’d have to use some kind of authentication measure (i.e. cookies) that could be read server-side, and then use NGINX to conditionally block/unblock content based on that. It looks like NGINX has access to cookies through internal variables: https://nginx.org/en/docs/http/ngx_http_core_module.html#variables That’s just a guess, though.

This topic was automatically closed after 42 days. New replies are no longer allowed.