Pre-Signed URLs

pineapplelife

New member
Does this plugin support pre-signed urls for media? Would like to potentially shift from Amazon S3 but I need URL/Image security.
 
Internally it does have the necessary functions to generate the pre-signed URLs so it wouldn’t be terribly hard to implement. Currently it attaches a public domain for WordPress media mainly because then you are able to serve that from Cloudflare’s edge (caching in data centers without needing to even do a read from the bucket).

Since the functions already exist, it wouldn’t be terribly hard to give the option to make the bucket private and media served via presigned URLs. It would end up being slower (and more class-B operations since you wouldn’t be able to leverage the CDN edge cache though).

Just out of curiosity, what’s your particular use-case, are you selling media (don’t want unregistered users able to see them)?
 
Internally it does have the necessary functions to generate the pre-signed URLs so it wouldn’t be terribly hard to implement. Currently it attaches a public domain for WordPress media mainly because then you are able to serve that from Cloudflare’s edge (caching in data centers without needing to even do a read from the bucket).

Since the functions already exist, it wouldn’t be terribly hard to give the option to make the bucket private and media served via presigned URLs. It would end up being slower (and more class-B operations since you wouldn’t be able to leverage the CDN edge cache though).

Just out of curiosity, what’s your particular use-case, are you selling media (don’t want unregistered users able to see them)?

That's promising, definitely interested in doing some work on this. The content I am protecting is member uploaded adult content.

Amazon S3 pre-signed URLs aren't too slow since they run thru Cloudfront, the more annoying issue is broken image links sometimes with caching.
 
Ya, you’d ideally want to route through something that can’t be cached that in turns generates the pre-signed URLs.

In your particular case, is everything within WordPress (for example are the users trying to access the content logged into WordPress user accounts)?
 
Ya, you’d ideally want to route through something that can’t be cached that in turns generates the pre-signed URLs.

In your particular case, is everything within WordPress (for example are the users trying to access the content logged into WordPress user accounts)?
Yes everything is only accessed by way of Wordpress and logged in user accounts.
 
Are there various permission levels, or is it just a situation where if someone is logged in, they should be able to access via a presigned URL?

Just someone logged onto the site, not doing any user level permissions. If they are a member of the site they can upload their content, access to the media is controlled by Wordpress but all media is pre-signed.
 
Honestly there probably isn’t going to be an easy/great way to do it with third-party things that are storing media in different locations. WordPress doesn’t have a generalized abstracted filesystem like some other platforms have. So because of that, to get something to support R2 (even default WordPress media) is coding for that specific thing (and a pain in the ass).

I keep hoping WordPress will add an abstracted filesystem so you would then just need to hook into the filesystem to make everything work, but I’m not holding my breath.
 
Honestly there probably isn’t going to be an easy/great way to do it with third-party things that are storing media in different locations. WordPress doesn’t have a generalized abstracted filesystem like some other platforms have. So because of that, to get something to support R2 (even default WordPress media) is coding for that specific thing (and a pain in the ass).

I keep hoping WordPress will add an abstracted filesystem so you would then just need to hook into the filesystem to make everything work, but I’m not holding my breath.

I thought that I had read that appforcf had some support for Buddyboss...assuming that code for BB related directories had been complete. I'm currently using Media Cloud for Wordpress which supports BB directories but they don't support R2 pre-signed, in addition while the plugin works pretty well it seems like there is very little support for new features as I can't even get someone from Media Cloud to respond to any requests.

So, I have been looking to replace Media Cloud with something having more Cloudflare support.
 
I thought that I had read that appforcf had some support for Buddyboss...assuming that code for BB related directories had been complete. I'm currently using Media Cloud for Wordpress which supports BB directories but they don't support R2 pre-signed, in addition while the plugin works pretty well it seems like there is very little support for new features as I can't even get someone from Media Cloud to respond to any requests.

So, I have been looking to replace Media Cloud with something having more Cloudflare support.
There certainly wouldn’t prevent Buddyboss (or anything else) from leveraging R2 via the plugin, but I’ve not heard of them working on that (they also wouldn’t need to tell us, so it’s possible they do). Do you have a link you could share about it? I could try to look around and see what they have/haven’t done.
 
There certainly wouldn’t prevent Buddyboss (or anything else) from leveraging R2 via the plugin, but I’ve not heard of them working on that (they also wouldn’t need to tell us, so it’s possible they do). Do you have a link you could share about it? I could try to look around and see what they have/haven’t done.

My mistake, I had thought that appforcf already had BB support but I must have confused this with some other plugin.

My goal is to leverage Cloudflare R2 using pre-signed URLs with the standard WP media library and the following custom directories:

uploads/avatars/
uploads/group-avatars/
uploads/media
uploads/bb_medias/
uploads/bb_videos/
uploads/bb_documents/
 
The way WordPress works internally, there's really not going to be a way to force third-party things to use R2 without explicitly getting into the third-party code to add support.

That would change *if* WordPress designed a better filesystem system, but right now WordPress really only supports the local filesystem internally. For example, if they had an abstracted filesystem that simply defaulted to "local", then you could do drop-in replacements for the filesystem itself. While other platforms do exactly that, it's a bit of a pipe dream for WordPress at this point to be honest (it's internals are so old/antiquated, I doubt we'll see that sort of change anytime soon).

That being said, I'm happy to help third-party devs add R2 support if they want (it would be fairly easy for them since the framework is done, all they need to do is add a couple lines of code to actually use the R2 library).

For at least supporting normal WordPress media with presigned URLs, it's fairly simple... I'm just trying to figure out how to do it and add settings for it in a way that's simple and not confusing for everyone else *not* trying to do presigned URLs. That's the tricky part.
 
The way WordPress works internally, there's really not going to be a way to force third-party things to use R2 without explicitly getting into the third-party code to add support.

That would change *if* WordPress designed a better filesystem system, but right now WordPress really only supports the local filesystem internally. For example, if they had an abstracted filesystem that simply defaulted to "local", then you could do drop-in replacements for the filesystem itself. While other platforms do exactly that, it's a bit of a pipe dream for WordPress at this point to be honest (it's internals are so old/antiquated, I doubt we'll see that sort of change anytime soon).

That being said, I'm happy to help third-party devs add R2 support if they want (it would be fairly easy for them since the framework is done, all they need to do is add a couple lines of code to actually use the R2 library).

For at least supporting normal WordPress media with presigned URLs, it's fairly simple... I'm just trying to figure out how to do it and add settings for it in a way that's simple and not confusing for everyone else *not* trying to do presigned URLs. That's the tricky part.

Makes sense and appreciate you looking into presigned URLs for R2. There are several plugins that allow custom directory offload to R2 and S3; Media Cloud, WP Offload Media, etc. I haven't looked at their code but I am assuming they are doing so by just extending the approach for the media library by pointing to different directories and url rewriting. If you are open to some custom development I would be happy to chat with you and see what is possible. Thanks!
 
If they are doing it in a way that they are hooking into WordPress actions/filters, it should be able to be done... but if they are doing it on their own, that's a different story. Like if they are trying to replace the WordPress Media system with something different, that's where it becomes more problematic, because now you are trying to keep up with third-party code (and future changes that could make what once work, break).

Have you picked up that I hate the fact that WordPress doesn't use an abstracted filesystem? 😂

Is there something those addons do that the WordPress Media section doesn't? Basically just wondering if there's actually a need to use those custom directories...
 
If they are doing it in a way that they are hooking into WordPress actions/filters, it should be able to be done... but if they are doing it on their own, that's a different story. Like if they are trying to replace the WordPress Media system with something different, that's where it becomes more problematic, because now you are trying to keep up with third-party code (and future changes that could make what once work, break).

Have you picked up that I hate the fact that WordPress doesn't use an abstracted filesystem? 😂

Is there something those addons do that the WordPress Media section doesn't? Basically just wondering if there's actually a need to use those custom directories...

100% agree on the lack of an abstracted filesystem. I don't know why BB made the decision to leverage a different file folder structure for media than the base media structure, could be a number of reasons that are not likely to change soon...much like the WP filesystem :)

I just want to figure out how to move off Media Cloud due to their lacking support, Media Cloud does support R2 but they don't support pre-signed URLs and since they don't respond to support requests I don't even know if this is something they are working on.

Also, I want to shift to R2 because I use all the other Cloudflare security / cdn / dns / etc features and for whatever reason Cloudflare has a 200MB limit on uploads flowing thru their proxy out to AWS BUT that restriction doesn't seem to be in place for R2 and their Video Stream. This 200MB limit will be a problem for me in the future so trying to figure out alternatives. Thanks!
 
Is it an option to move the existing Media Cloud media back into WordPress Media? If they aren’t being responsive to general support, they probably aren’t going to be helpful with trying to add R2 support in their plugin.
 
Is it an option to move the existing Media Cloud media back into WordPress Media? If they aren’t being responsive to general support, they probably aren’t going to be helpful with trying to add R2 support in their plugin.

Media Cloud already supports Wordpress Media and custom directories, also supports pre-signed URLs for S3, also supports R2...but not R2 pre-signed URLs. Agree with you that they probably aren't going to be helpful with enhancements.

This is why I need another method to leverage R2, a method that supports custom directories and R2 pre-signed URLs.
 
Back
Top