Author Topic: Remote download  (Read 5642 times)

soulviasound

  • Beginner
  • *
  • Posts: 2
Remote download
« on: March 01, 2011, 17:36:45 pm »

I'm looking for someone to resolve this php problem:

VM(last verssion) + Joomla 1.5.22 hosted by fatcow

I have problem with download of large files. I already set remote download from Amazon S3 bucket, but I get corrupt files.

I need soon as possible. Name your price, payment via paypal.

shimi

  • Beginner
  • *
  • Posts: 6
Re: Remote download
« Reply #1 on: March 01, 2011, 18:00:47 pm »
How big are the files?

soulviasound

  • Beginner
  • *
  • Posts: 2
Re: Remote download
« Reply #2 on: March 01, 2011, 18:28:20 pm »
2 x 1GB files and 2 x 100MB files. And strange thing, in normal mode (folder ouside of webroot), no buckets3 solution, works the 2 100mb file fine but doesn't work 1GB.

I think it's about serving headers from connectionTools.class.php but it's just an amateur "thinking".

It drive me crazy.

lowmips

  • Global Moderator
  • Full Member
  • *
  • Posts: 1464
    • lowmips.com
Re: Remote download
« Reply #3 on: March 01, 2011, 21:52:23 pm »
Are you seeing a timeout issue? 1gb is going to take a long time to download.
Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

soulviasound

  • Beginner
  • *
  • Posts: 2
Re: Remote download
« Reply #4 on: March 06, 2011, 00:25:24 am »
With Amazon S3 I get a 1kb file, in normal mode, download doesn't start so a timeout is present there.   

chetanmadaan

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 291
Re: Remote download
« Reply #5 on: April 04, 2011, 23:45:49 pm »
well - i see the class ps_product_files.php downloads the remote file temporarily and then gives it out.

is there a way we can stop this and use a direct download function????

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Remote download
« Reply #6 on: May 03, 2011, 07:48:47 am »
I can think of 2 solutions to this problem:

1. Simply start the download through the direct link (the user never sees the link, but they CAN see it, which poses a problem for sellable downloads). Here's how I accomplished this:

In ps_order.php in the download_request() function where it checks if it's a remote file, I added the following line which starts a download for the user directly from Amazon S3.

Code: [Select]
header( 'Location: '.$datei ) ;
The advantage here is that the actual download process is handled by Amazon's servers which is faster and more reliable than most web servers. This takes a load off the web server. The obvious disadvantage here is that the direct link can easily be discovered and distributed and the number of downloads couldn't be tracked.

2. This one is a lot more complicated, but I would assume it's possible to write code to make a copy of the downloadable file in a temp directory on Amazon S3 specifically for that download ID and have the temp file deleted once the download expires. This would require a good bit of coding and could bloat the storage on Amazon S3 if there are a lot of downloads (say you sell 1000 2GB movies, that's 2000GB of storage now!).

I'm still working on this problem because this is VERY important for my project that I have security but also be able to deliver large files to the user without burdening the web server. I'm currently trying to understand if it's possible to deliver the file (chunk by chunk) to the user through the web server without the file ever being downloaded to the web server. If anyone can offer any info on this, I'd appreciate it.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

fandy

  • Readers
  • *
  • Posts: 0
Re: Remote download
« Reply #7 on: May 06, 2011, 11:29:55 am »
I'm looking for someone to resolve this php problem

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Remote download
« Reply #8 on: May 17, 2011, 06:34:46 am »
Fandy, in my last post, I suggested (in option 2) leveraging Amazon's APIs to copy the files to a temporary location and give the user this temp URL. I've actually implemented this and am going live with the site tomorrow. The downloads are handled through VM so the max downloads and download lifetime policies are implemented. Even if the user gets the direct link to the temp file and shares it, the file will be deleted when the download expires, so this should lower the risk of piracy in digital sales. I'm interested in doing some work, so just PM me.

Stephen
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Remote download
« Reply #9 on: June 13, 2011, 19:01:12 pm »
So after some research I discovered that there is a much better way to handle secure downloads than my previous solution of copying files to a temporary location. I'm sure other people have known about this, but apparently you can create pre-signed URLs that allow users to authenticate to Amazon S3 to access files. These pre-signed URLs also have an expiration date. This seems like a more secure way than my previous solution. I'm thinking about creating an Amazon S3 plugin for VirtueMart.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com