Help Needed Using Advanced Download Restrictions

I have been pulling my hair out trying to bypass the S2 download restriction. If anyone can offer any ideas I would be hugely grateful.

I want to allow visitors to my site to download a ZIP file which is held on Amazon S3.

The page containing the link to this is unrestricted and works fine if the visitor is logged in as a member of my site. But, I need to allow anyone to use the link and not just signed in members. If a visitor who isn’t logged in tries to download the file they are redirected back to my homepage.

To allow anyone to download the file I have been trying to use the “Advanced Download Restrictions” in S2 Member under the “Download Options” section. This says I can use either PHP or a shortcode to create a temporary download key that will allow anyone to download the file.

I have tried both methods and receive the same error in both cases.

503 (Invalid Key): Sorry, your access to this file has expired. Please contact Support for assistance.

Here is an example of the path and shortcode being used

https://lenscraft.co.uk/?s2member_file_download=mastering-photoshop-masks.zip&s2member_file_download_key=[s2Key file_download=“mastering-photoshop-masks.zip” /]

If anyone can suggest a solution or how to work around this (whilst keeping the file off S3) you would make me very happy.

Thanks

Hi Robin, Is there a reason you don’t want to just host the file in your WordPress site in the media area? :slight_smile: Sounds like you could then just have it on any page you wanted and be accessed by any person you wanted as well? :slight_smile:

There isn’t just 1 file but rather 20 and the total size is 1.3Gb. I was trying to simplify the situation to make the post easier to understand.

I use Amazon S3 to serve this to the user as it gives a good download speed. A self-hosted file is much slower to download and takes up much more bandwidth. It would also interfere with backup arrangements on the site and create a few other “minor” but frustrating problems.

It’s a bit like trying to serve a video from your site, it can be done but it’s not recommended.

Have you tried letting s2Member auto-generate the key by using the following syntax?

[s2File download="example-file.zip" download_key="true" /]
1 Like

Thanks for the suggestion Tim. I have previously tried this shortcode which was my favored option but it failed. I’ve now done more investigation and it still fails when I test with Edge. When I test with Chrome I can achieve a download but only if I use the shortcode inside a standard text link.

When I try to use the shortcode within a button, either the button vanishes or links to a blank screen with no download. The results seem to be inconsistent but it appears to be some sort of conflict with my theme (Divi). I will investigate further but may need to adopt a text link.

Thanks for getting me to revisit this option. It may yet work for me.

Hi Robin,
I actually serve 200 teaching videos from my site and never had a download speed complaint :slight_smile:
What about rethinking the delivery model and combining some of the files, etc?
Just thinking aloud :slight_smile:

Thanks, but I’m not going to migrate to a new site infrastructure because a feature of a plugin doesn’t work as described.

Following the suggestion from “KT S915” I have been able to create a working link. Based on this I can see that the example link in the S2 help text differs. Here’s a section of the text

https://lenscraft.co.uk/?s2member_file_download=example-file.zip&s2member_file_download_key=<?php echo s2member_file_download_key("example-file.zip"); ?>

This builds the link and concatenates the download key at the end of the link. When you have S2 build an entire link with using the shortcode [s2File download=“example-file.zip” download_key=“true” /] you find the construction is different. What you have is

“domain” + “download key” + “S2 download location”

When I switch the link construction to this format it works and I don’t receive the “invalid key” message. It looks like the description on the “Download Restrictions” > “Advanced Downloads Option” needs updating.

@rnwhalley, would you mind adding this as an issue on the s2Member Github pages? See https://github.com/WebSharks/s2Member/issues

It is much more likely to get addressed if it’s added there.

1 Like

Thanks for the suggestion. I have added it.

1 Like