Is this how the user connects to their file downloads?

Posts: 10
Joined: 04/15/2008

I've set up a product which allows file downloads and the user can connect to the file through an email link.

The product is set to download the file and send an email to the user after a "completed" order staus is generated for the order. The product has an assigned a model#, permissions for "file download" are enabled, and once the order status goes to "completed" via a Workflow-ng rule, I can see the file download in the user account under user accounts > files.

The email is automatically generated and is sent to the user.
the link to the file has a format of - http://www.whatever_the_domain_name_is.com/download/X/33820a8554f0fb8878...

If I click the link, I get the error seen on the attachment listed with this post and it says:

"Internet Explorer cannot download 33820a8554f0fb8878a9488ab5ff3627 from www.whatever_the_domain_name_is.com"
Internet Explorer was not able to open this internet site. The requested site is either unavailable of cannot be found. Please try again later"

I get this error if the user is not logged into my site when the download link is clicked.
But, if the user is logged in, the file can be accessed

So, I believe that this is my solution, I've tried to work this out many different ways and always got either an "Access Denied" error or the error I just wrote about.

Since the file download link string does not contain login and password info, am I right to let my users know that they must be logged in to view their file downloads?

Thanks

AttachmentSize
file download error.JPG30.89 KB
Posts: 1290
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

The links sent via email are one-time-use-only links. But it should work at the first click, as long as you have the "Download file" permissions set to allow Anonymous users.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 10
Joined: 04/15/2008

thanks for the follow-up, torgos

Yeah, I've got the file download permissions enabled for all roles - in fact, its been some of your posts that have helped me out in this project considerably, so, thanks much.

The user documentation doesen't say if the user has to be logged in to allow the user to access their downloads, but from the general threads on this topic, it sounds like users do not need to be logged in for this to work.

Should my setup allow for downloads without the user logging in first?

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

Glad I can help.

Your setup, assuming you've got the permissions configured right, should allow for anonymous downloads. (I've tested this on mine and it seems to work..) Are you running the latest version? I thought you said you were. I can't test at the moment but I can run a quick check tomorrow morning. It might be an issue with the module, but I'm kind of doubting that right now.

I think keeping users logged in is the best way to go anyways, but if you really need anonymous users and it isn't working, let me know and I'll attempt to track it down. (If I can reproduce the issue, which I might not be able to).

Sorry this is vague - that's what happens when I can't really see the same issue that's being presented, at least, I haven't experienced it thus far!

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 10
Joined: 04/15/2008

I just downloaded the Drupal 5.x and UC bundled tar from the UC site two days ago so its a state-of-the-art UC install.

The file permissions are all enabled for file download so this should be a mute point - there is another file downloads permission for "view all downloads" but my understanding is that this should be restricted to admin-types, right?

Thanks again for the follow-up

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

Yeah I'm .. pretty sure thats for admin types. I will double check.

Just so I'm clear, the email links only work for you if you're also logged into the site? Have you tried them without logging in first? In the past I have successfully downloaded the one-time links from the email, and then after that one use they expire. Is this what you are experiencing? I think your issue is separate though, from the sounds of it. Like I said I'll try to double check.. meanwhile if any of the Uberguys have thoughts feel free to post 'em here.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

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

Yeah that is an admin permission, it looks like. Question: do you get any logs in Watchdog for this? And have you overridden the themed downloads token function? I doubt you have but figured I'd ask.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 10
Joined: 04/15/2008

Right, the links will work only if I'm logged in as the user who ordered the download - if not logged in it generates the error message.

The files, once they go to completed status(i'm working this issue too with a W-ng config), are easy enough to get to.
My workaround for this will be to autogenerate the file downloads email but omit the [file-downloads] token from the body of the email and instead have the user login to download the file. Simple enough but I still want to have all the functionality in place b4 I go live.

Posts: 10
Joined: 04/15/2008

I missed your second post a while ago...

watchdog has been logging the errors - I don't know enough about them to tell you what's going on though. But the watchdog errors refer to a .css file in a /files/css path while the email link path is /download/1/the string of alpha-numerics - and the string value for each is different. Is this just how watchdog looks to get the error info?

As far as themed downloads token, I dunno...

The only time I've modified anything that had tokens included was to add some text to the
admin/store/settings/notify/edit/file message text field to point the user to the url of my site to login in case they could not download the file via the link. Other than that, I'm not familiar enough with themed downloads to tell you if I've changed anything else.

In any event the [file-downloads] token was always present in the file download email.

Posts: 14
Joined: 05/31/2008

Ever figure this out? I'm having the same issue!

It seems to only be an issue on IE...Firefox works like a charm.

Posts: 14
Joined: 05/31/2008

I've tested this everyway right of Sunday.

Firefox logged in...works.
Firefox logged out ...works
IE logged in...fails!
IE logged out...fails!

Something wrong with the way the data is streaming to IE or else the headers. The file starts then fails. Also the drupal/ubercart log shows the file was downloaded successfully, even though it wasn't.

If I find a solution, I will post here.

Artis

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

Just so we're on the same page - you are able to download the files via:

Firefox - My Files area
Firefox - Linked from email

but NOT

MSIE - My Files area, or
MSIE - Linked from email

Is that correct? The function to send the file data to isn't anything special. What version of IE are you using? Are you clicking on the file, or right-clicking and choosing "Select Target As"? (That was the one time it hiccuped for me, but after that, right-clicking works ok.)

NOTE: I did see this issue occur once in Internet Explorer 6. But I can't reproduce it. If you can reproduce it every time, please let me know what steps exactly you are using to duplicate the problem so I can look at it Smiling

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 14
Joined: 05/31/2008

Thanks for replying...I've been hammering away at this for a while now.

Firefox works in any situation.
IE7 works in My Files Area.

IE7 does NOT work from email link.

Also, the files are PDF. I've found others who had problems with IE6 & IE7 and PDF's...seems to be related to file extension (.pdf) and Content-Type header not matching. I've changed line 1093 uc_file.module to 'Content-Type: application/pdf' for testing...still doesn't work.

It is reproducible...every time.

The error says:

"Internet Explorer cannot download 33820a8554f0fb8878a9488ab5ff3627 from www.whatever_the_domain_name_is.com"
Internet Explorer was not able to open this internet site. The requested site is either unavailable of cannot be found. Please try again later"

I think it's interesting that the error has the hash in it instead of the filename? Should that concern us?

Thanks for the help! I hack a little php but not fluent by any means.

Artis

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

Well from that it looks like it's just missing the protocol... can you view the source of your email? I'm fairly certain the file downloads mail function automatically, using the l() function add the http:// protocols to all of the links it generates.

I'll test a bit on my end and see if I can come up with anything...

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 14
Joined: 05/31/2008

Protocol is there. I even copy and past it into the browser...still doesn't work.

If you want to see what happens goto: www.upagainstevil.com Click on the Free Download and complete the free purchase. When you get the email open it with IE and you'll see. I'll delete your customer data after we are done.

Thanks.
Artis

Posts: 14
Joined: 05/31/2008

One other thing...I just tried copying the link from the File Download user table when I'm logged in and pasting it into the address bar of my browser....same failure. Whereas if I click on the EXACT same link it works. It seems to be something about how IE handles the address when entered in the address bar. Just thinking out loud.

Artis

BTW I'm using Ubercart RC5 and Drupal 5.7

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

I am getting "not a valid download link" on subsequent attempts. I did see the error message you're referring to. After trying a couple different things I was brought to the login page with "Access denied." And I can't login or request a new password.

So some questions:

Do you have permissions set for Anonymous users to download files? Or is that not what you are intending? In that case you'll need to adjust it so users must register before purchasing, or allow anonymous users to download files.

The other thing is, try what happens when you download the file from http:// and not https://. When I was in IE and I went through the secure (https) protocol I got the error .Once I removed the "s" (http://) I was able to at least get to the "this is not a valid download link" error screen.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 14
Joined: 05/31/2008

I have permissions set for Anonymous to download. I also don't send out user information and users that are created automatically are blocked. I'd rather users not even be created in the first place but that's not possible with Ubercart at the time.

Both http:// and https:// give the same error. The error only occurs the first time because the link expires after that. That's why you get "this is not a valid download link" after the first try. I'll send you a new link and you can try it without ssl to see. The email shows https:// because I have the checkout pages secure so that's the drupalbase url when the email link is generated. I was getting the error with SecurePages turned off so it isn't the problem.

Artis

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

Interesting. So now if I were able to login and retrieve the file via My Files, I wouldn't have a problem? I wonder if there is something with the way these temporary download links are being constructed that is the issue? Can you compare the links from the email, to the ones in My Files, and see if they are different? I will test on my site so I can see for myself...

EDIT: The links don't give me this issue for my site... so it might just be a configuration issue.. and the links do look the same but I'm wondering how the emailed ones are temporary, while the ones in My Files are not? Guess I need to familiarize myself with that a bit more.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 14
Joined: 05/31/2008

The files are the same...it has to do with how the url is parsed maybe?

The My Files and the email urls are the same...when you click on either of them the "HASH" part (after last '/') is regernerated and entered in uc_file table and the access is incremented by one. That way the email link only works once and only if it is clicked BEFORE the My Files link is clicked. Otherwise the HASH will change and the email url won't work even though it hasn't been clicked.

Now back to the issue... I think it has to do with how the uc_file module parses the url and generates the fopen and header information. I think when clicked from My Files (function uc_file_user_downloads) there is relative link href "/download/8/j3fjopa9fjp..." where as the full "http://www.sitename.com/download/8/feoau93fa" is in the address bar from the email link. Does drupal handle these differently?

Posts: 14
Joined: 05/31/2008

I just noticed that the My Files link also has a Onclick that loads up the uc_file.js file. The direct link wouldn't have that...could uc_file module be expecting that funtion somewhere and failing? Why wouldn't it fail on FF also?

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

Nah, the only thing the JS does is increment the access log (and makes your "Downloaded" number increase by 1).

I've done some testing but it's not really an easily duplicated problem for me. I don't believe the URLs get parsed any differently depending on the browser. My guess is something to do with the link itself... but I could be wrong. I'm still trying to figure out why the temporary link would get that kind of status... there must be something that gets checked, or passed, that lets the system know that you are downloading via an external link vs. downloading from the files list.

I don't have much time to look into it now but I will soon as I can.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 14
Joined: 05/31/2008

yes...I'm back to this being an issue with the headers in _file_download_transfer in uc_file.module. I think it makes sense...If the link is clicked from a page that is already rendered the headers work, but if you click an email link or copy/paste the address the headers are missing something and/or including something that is breaking the download.

Posts: 14
Joined: 05/31/2008

It has to do with having SSL on the server. IE can't save the file with:

Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate

in the http headers. Something about needing a local cache version to pass to the download manager or file reader (i.e. Adobe Reader). See: http://support.microsoft.com/kb/316431

So changing those lines to:

Pragma: public
Cache-control: public

works perfectly. Those lines are in function "_file_download_transfer" around line 1080 or something (I've hacked this file so much I don't know the exact number.

I know this isn't ideal for protecting the files but it works. Maybe some sort of test for SSL could be written in and then the corresponding headers could be passed?

Thanks for the help, torgosPizza!

Artis

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

Ahh, interesting. I hadn't even thought of it.

This is actually a change I had made to my own module, because when looking into integration with a CDN, (which caches the content you send to it), you need to pass the cache-control header. Setting it to "no-cache" prevents a CDN's caching system from picking up the content in the first place - hence, defeating the purpose of going with a content caching solution.

Interesting that this would have that sort of effect on IE and not other browsers... good catch, I'm glad you got it working. I bet you that's what is causing all the related errors, including the "not a valid download link" that seems to appear every other time..

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 5245
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I'm a little ignorant of all that's gone on in this thread, but I definitely want to applaud your efforts in the troubleshooting here. You guys are excellent. I'm just curious if there's anything we need to do to the module to avoid this problem in the future for other users.

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

Well, the thing is that the default headers allowed for keeping the content fresh (due to its no-cache parameter). Unfortunately this seems to be what was causing this and probably other issues. My off-the-cuff suggestions would be:

1) Make the headers cached and public by default, but allow for this to be a config option, and/or
2) Move some of those functions to a themeable function. I had posted this a while back, but there are a couple functions I think could use overriding. Here's one I mentioned.

The ideal thing, IMO, would be to make the functions involving the download process and the My Files section themed functions, so they can be overridden and changed. Two case studies I have for this are from our own site:

- With the download process if I needed to send the user to a different location (such as through Amazon S3 or another CDN that doesn't have current Ubercart support) I would need to go and hack the uc_file.module to make that happen. Another example is the changing of the headers as discussed here.

- The My Files area being themed would just be icing, so that we can change the default view to have different columns, sorting, jQuery effects (along the lines of my first crack at cPill's uc_file_downloads.module).

I think the more flexibility the better, especially if the definition of a product file becomes more abstract.

Those are just some ideas, YMMV as always. I'm always willing to help out in any way - especially something like this that'll allow more flexibility, without losing functionality.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 14
Joined: 05/31/2008

All of that sounds good and is mostly over my head! Smiling

I don't know if it's easy or possible to detect if the server has an SSL cert installed. If so... use one set of headers...if not...use other set.

Or like torgos said.. make the headers a config option and the site admin can choose "SSL headers" or "Protected headers"

Artis

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

I didn't read that article yet, but from the sounds of it, SSL shouldn't make a difference..? Well I'll investigate more and provide Ryan etc. with an outline to help out. Soon as I get some time, that is Smiling

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 10
Joined: 08/12/2008

Hi there, I was just wondering if there is any follow up to this issue. I'm seeing the exact same problem as AEWilliams on IE7 (but not on Firefox). Can we expect the fix to be in an upcoming release? If not, can someone post the exact fix with line numbers and such?

As a side observation about anonymous downloads, reading through a lot of the forum postings over the last week, I've noticed that the feature was not designed for one-shot buyers in mind. (Yes, I'm making some gross generalizations here so bear with me.) For example, the most typical use case for my site would be a user buys one product, gets an email with the link, downloads the files and that's it. I don't really need or want that user to have an account on my site, although I am giving them the option. With that in mind, I've found that getting to this point in terms of configuration has been challenging. I'm not complaining though, and I am grateful for all the effort that people have put into making UC great. I realize that it's hard to predict how people will use a feature and I'm glad that we have this forum to hash things out and share our experiences.

Posts: 14
Joined: 05/31/2008

Lines 1087-1090:

      'Pragma: public',
      'Expires: 0',
      //'Cache-Control: no-cache, must-revalidate',
      'Cache-Control: public',

Posts: 5245
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

torgosPizza just posted a patch for 1.4 that I want to try and get into core. cha0s tested it and it worked fine. I'd love to get some more feedback so I can feel confident committing it.

Check it out here - http://www.ubercart.org/issue/4846/making_uc_file_file_downloads_support...

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

I realize some of the code might not be up to Drupal standards, I tried my best to keep it that way - but feel free to improve it as you see fit. I think it would work for the one-shot buyers as was mentioned above, as well.

EDIT: On second thought, I can take a look at it again this morning, and review it for an improved patch. I was so excited to get the resume functionality to work, I might have missed some Drupal standards things. I'll give it another glance and submit a new patch later today, unless you decide to roll with what I've already got.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 5245
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I don't have any problem waiting. Smiling

Like I said, cha0s was able to patch and get it running, so code cleanup would be icing on the cake! It looks like one thing is the use of tabs instead of the two spaces, but my IDE strips those out when I save anyways.

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

Ah, so you're saying I should convert my tabs to use spaces in jEdit? Can do Smiling

I'll look at cleaning the code up here in a bit and resubmit the patch.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 10
Joined: 08/12/2008

If you can post the file here as an attachment, I'd be happy to patch my test system and give it a try. Thanks.

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

I posted it at the end of the original thread: http://www.ubercart.org/issue/4846/making_uc_file_file_downloads_support...

Let me know how it works for you!

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 10
Joined: 08/12/2008

Just wanted to give a follow-up on this issue:

Using the latest UC 5.x-1.5 the download email works for anonymous users on IE7, Firefox 3, and Chrome. Yay!