File Downloads - error message after first download

Posts: 18
Joined: 05/08/2008

Hi, I think I have my file downloads set up properly, user can recieve a download and opens up fine the first time (its just a plain text .txt file)

The second time it's clicked, there is an error message :

The following URL is not a valid download link. Please contact the site administrator if this message has been received in error.

But the link downloads fine anyway. Is there any reason for this? I am on a live server, not test.

My files are in a private folder alongside the web root. The dowmload limit is set to never.

thanks for any assistance, much appreciating Ubercart and all the help I have recieved here.

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

That is really strange... that error message only gets called when a user is denied access to a file - but it still pops up with a download dialogue box for you?

Are you using the public or private files method? (You need to be on public for the module to function 100%)

That's all I can think of for now.. do your Watchdog logs mention anything about a user being denied, and why?

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 18
Joined: 05/08/2008

I have also checked the download limit, it's blank = no limit.

The logs show nothing untoward:

user 05/17/2008 - 01:39 Session closed for user2. user2
uc_file 05/17/2008 - 01:38 The user user2 has ... user2
user 05/17/2008 - 01:38 Session opened for user2. user2
user 05/17/2008 - 01:37 Session closed for superadmin. superadmin
user 05/17/2008 - 01:37 Session opened for superadmin. superadmin
user 05/17/2008 - 01:36 Session closed for user2. user2
user 05/17/2008 - 01:36 Session opened for user2. user2

User2 orders the download... i log in as superuser to switch the order status to complete (I am still just using Credit Card and Test Gateway), log out, log in User2... again, get the download once, then the error mesage, then can download, then the error...it alternates.

Doesnt really mess up the workings of my site but obviously dont want to be spitting meaningless errors at users.

Hope this makes my situation clearer if nothing else! Thanks!

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Can you make sure your access settings for File Downloads are setup correctly? Just trying to cover all bases...

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 18
Joined: 05/08/2008

Authenticated, Shop admin and site admin (superuser) have download file permission. Not anonymous.

Have tried view all downloads with authenticated both allowed and disallowed, same outcome. hmmm.....?

Posts: 48
Joined: 10/20/2007

Forgive me if this is the equivalent of asking "is it plugged in?" but are you reloading the file downloads page between attempts to download? The download URL is generated anew for each download of the file, so if you download the file and then click on the link again without reloading, you'll get that error message. It's dynamically generated to avoid people being able to leech your file products. But if you're getting that message and people are still getting the download popup, then that doesn't really seem like the problem...

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Actually, it's not - the "one-time use only" links are emailed to the customer, but the links in the My Files area are static. The key that is generated for the link (which becomes part of the link) is stored in the uc_file_users table. That's the main part of authentication, along with the uid-fid association.

So, the problem is that it seems to be failing the authentication, while at the same time passing it. It's almost like it's clicking two different links. I'm trying to think of what would cause that... Have you themed or overwritten the function for the user downloads area? are you using the link with a download manager of any type?

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 18
Joined: 05/08/2008

Hi, I haven't overwritten or themed anything on the site.
I have used both Firefox and IE7 to download the link and get the same message on the page (it's in a red box above the list of downloads just to be specific). Sorry, don't know if any of that's relevant but this is beyond my expertise, such as it is!

You're right though, it does seem to be failing and passing some kind of authentication at the same time.

Just to clarify, I'm using public files method. my temporary directory is set at /tmp in the httpdocs folder, the downloads are served from my private folder alongside the webroot. Is this the recommended setup?

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

That might be a clue - is your temporary folder /tmp configured that way? In other words, is it configured with the leading slash and then "tmp"? If so, that would mean that you are configuring it with an absolute path, which is the normal scenario at least for dedicated servers. If you are on shared hosting, this might cause an issue. My guess is that the issue is not actually with the module itself but with some other server-side config that is just tripping an error, which the uc_file.module doesn't quite understand how to parse.

The next question is for your "private" folder - I don't believe you need to chmod it 777 but that's what I have done with our downloads folder on our dedicated box. Try doing that and see if it changes anything. You might also try the different configs - absolute path vs. relative path. I believe both are acceptable, but absolute path is always recommended. It should be something like...

/tmp (temporary folder)
/var/www/vhosts/example.com/downloads_folder (folder alongside webroot)

Not sure if this is out of your expertise as well - but try tinkering with some settings there, so long as you don't mind changing things. I don't want you to break anything on the site Smiling (But there is (almost) always a fix!)

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 18
Joined: 05/08/2008

hmm, i have tried both public and private system with the following:

tmp (as my temporary folder)
/var/www/vhosts/example.com/private as my downloads folder

the private file is set to 777. is the temp folder supposed to be in the webroot (ie should it located at httpdocs/tmp? or alongside the webroot like the private folder? ( i dont have permissions to create a folder alongside the web root from my shared host accoount, although they altered the open_basedir restriction for me to make my private file writable so i guess they would set up another folder there if necessary.

So I guess what I'm asking is, if I did set my temp folder to /tmp rather than tmp, where is that located?

Hope this makes sense! Still finding the relative/absolute thing a little confusing, thanks for your patience and help.

Posts: 18
Joined: 05/08/2008

Hmm, still not solved this one. Have moved my site onto production server, everything working ok (so far, i have only tested with a test gateway, will be using PayPal WPS soon). still getting the error message on every other click on a filename in the downloads area of account profiles.

it downloads fine every other time, alternating with the error message "the following URL is nor a valid download link". weird.

Anyone got any ideas? Cheers!

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Are you using Internet Explorer by any chance? Have you tested this in other browsers?

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 18
Joined: 05/08/2008

I always develop in Firefox, only use IE for testing. Have tried in IE7 with same results. Like I say, allows the download anyway if I click again - so it works, but probably not instilling a lot of faith in the customer (or my client!) if error messages pop up in the download process.

I suppose if it came to it I could remove the error message from wherever it's being called and print some white space, but that seems a bit dirty Smiling

EDIT

I've just realised this happens only when I try to download the file twice in succession -

e.g. if i download, then go to another page in my account say 'Orders', then go back to 'Downloads', the file is happy to be downloaded again, no error message. SO it only happens if I try to download the file twice consecutively whilst on the 'Downloads' page in 'My Account'.

Does this shed any light? Cheers!

Posts: 18
Joined: 05/08/2008

Have gone live now, still with (i hope) just this one nagging glitch? Anyone else got any ideas?
Thank you!

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

One suggestion I have is to edit the headers function of the uc_file.module as per this comment:

http://www.ubercart.org/forum/support/4303/how_user_connects_their_file_...

It's basically changing the headers sent to the browser to be public and cacheable. I think this is mainly a browser issue and has only been observed in IE, but it's worth a shot and shouldn't have any side effects.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com