Download links from S3 not working for purchases

I'm having a problem downloading files that we have purchased using MarketPress.
We've done two purchases, and the download links are going out with the emails properly, but the links never go to the ZIP file downloads.

The admin page for the order shows the file has not been downloaded, either. No error messages are

The files are being hosted on Amazon S3, and have been made available for download (We saw another error when the file hadn't been made public)

I have just tried this with the file linking to another public server, with a JPG instead of the ZIP, and this worked. Both files should be accessible through the links being used.

  • Alexander

    @grahamlindsey,

    It sounds like the link is changing from the time it is sent to the user.
    Can you give an example of a direct link to a file on S3? (maybe just a dummy file uploaded to S3) Anything that you can just enter in your browser now and receive the file from amazon.

    If you'd like to do this privately, just send it to me through the contact form. Include my name in the subject "Alexander Rohmann" and a link back to this thread as well.

    Also, what happens when you click the link in an email? Does it go anywhere?

    Finally, can you confirm you're using the latest version of MarketPress for me? (v 2.8.8)

    Best regards

  • Alexander

    @grahamlindsey,

    I've looked into this, and it has to do with the file size. By default, MarketPress will retrieve a copy of the file first, then serve that file to the user. The entire file would be copied into the server's memory.

    What you will need to do, is enable large downloads. You can do this by adding the following to your wp-config.php file.

    define("MP_LARGE_DOWNLOADS",true);

    This will have the user download the file from S3 directly. This is less secure, because you're doing a redirect, but will get the job done.

    Best regards

  • grahamlindsey

    Interesting - when it was taking a while to load, I wondered if it had to do with the size of the file.

    Can I ask if this means the user will see the file URL in the browser when downloading? This might not work for us, as the files that are currently being served are a series of albums, and the current SKUs (Which we're naming them with) will quickly reveal how to download the other files.

    This would also give the user a direct link to the file that they can bypass the download limit with.

    If these files are not bigger than 200MB, is it possible to set it up so that the entire file can be loaded into memory? This might be a question for our webhost, but it's also good to know that MarketPress/Wordpress will allow this, too.

  • Alexander

    @grahamlindsey,

    Yes, the user will be sent to the direct URL. So someone smart could turn this around.

    I wouldn't recommend having your server work with large files like this. This will slow down your site for other users, and create more bottlenecks - it will also use up twice as much bandwidth as you'll be paying S3 for the download as well as using bandwidth with your host.

    Now, what I would recommend is pursuing a deeper Amazon S3 integration. The S3 API allows you to create what is called a pre signed URL. Then you could filter the MarketPress download URL to allow this to happen

    For example, you could create a plugin containing this:

    define('MP_LARGE_DOWNLOADS',true);
    
    add_filter('mp_download_url','mp_s3_download');
    
    function mp_s3_download($url, $order, $download) {
    
        $url = ... Code to create pre-signed URL based on current URL
    
        return $url;
    
    }

    The AWS SDK allows for pre-signed URLs to easily be created based on your AWS accessID and secret.

    This would require custom development, but would be the best approach here.

    Best regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.