Download issues with self-hosted integration

timconsidinetimconsidine Member
in Help edited March 2014
After installing and tinkering, I am having 2 issues
1) emails being issued and process appears to complete, but datafeed error reported

2) user cannot download from generated email link
What file and directory permissions should the download have?
Have tried putting the download directory outside of public_html and also inside - no joy either way

How should the target directory be shown in config.inc.php ?
I have used '/digital/downloads' w/o host name as documentation doesn't suggest it needs one
But if outside public_html directory, I wonder if this works

Bashed my head around this for few hours and can't see the issues.
Please save me !! ;-)
Thank you !

Tim
Comments
  • fc_adamfc_adam FoxyCart Team
    @timconsidine,

    Sorry to hear you're having problems! We'll try to help get this sorted!

    1) Could you let us know what store this is for? We'll take a look at your datafeed errors and see if we can offer any advice for that.

    2) The files need to be publicly accessible - so that will be inside of your public_html directory. Do you get a specific message when you try to click on one of the links?

  • Hi Adam

    this is for salad.foxyxart.com (salad seminars)
    The website has a holding page, but the site is live using direct links if needed

    I only seem to see the start of the datafeed errors
    I am using the fc_interceptor to pass data to my CMS (perch) and also to the self-hosted system.
    The perch datafeed completes fine, but the self-host integration is returning an error (or maybe just failing to return 'foxy') but is generating emails with download product links

    The download dir is currently in the public_html directory.
    The documentation says better not, and I would prefer not, but I just need to get working

    Thank you for your prompt assistance

    Tim
  • fc_adamfc_adam FoxyCart Team
    @timconsidine,

    It sounds to me like you've got your 'generateLink' file set to have debug on. You can turn that off at the top with this variable:
    $debug = 0
    

    Could you whisper us one of your download links that you've been emailed to take a look at that?
  • Ooops ! Thanks Adam, I turned it on to debug and seem to have forgotten to turn it off.

    I'll whisper the link in a mo
  • fc_adamfc_adam FoxyCart Team
    @timconsidine,

    So the error that the download link is providing is related to a check to see if the file is available and readable from the location set for the file. That file path is made up of the $FILE_PATH config variable and the file_location set in the DB for the product.

    The combination of these two things isn't pointing correctly to the file for your product, and at a guess I'm going to say its your FILE_PATH value. You may need to set it to be relative from the root directory, or set it relative to that download file like '../digital/downloads' - or whatever your folder is.
  • Hi Adam

    Thank you.
    You said 2 very important things.
    Firstly, the file path may be relative and not absolute, and relative to download.php.
    Brilliant ! I only wish the documentation for the script was so clear.
    I'll email the developer - it would have made it so much easier to know this.
    Actually I should have thought of it, so I am feeling it a little silly !

    The 2nd point is that it is not clear that the FILE_PATH and file_location in DB is ... A COMBINATION !!
    The documentation doesn't make this clear - I thought it needed specifying in full separately, for different parts of the script.
    Discovering that the 2 elements work together, I have amended the config so that one piece of the path (the top level directory specified as relative to download.php, e.g. "../digital/") is specified in the FILE_PATH (ending with /), and the 2nd piece (the sub-directory) is specified in the DB e.g. "downloads/".

    With this combination, the complete path is constructed as "../digital/downloads/" relative to location of download.php .......... AND IT WORKS ! :-)) Well, kinda.

    A file is downloaded, but it is of zero bytes. The server copy is 29.7Mb so definitely a file there, but not coming down intact.

    But hey 2 important pieces of progress - thank you !

    If you have any thoughts on why it is zero bytes, I'd be very interested and grateful.
    Hoping to go live tonight before the working week !

    Thanks

    Tim
  • Update
    I have seen elsewhere on t'internet taht PHP max_execution_time can cause a problem.
    I have amended my default setting of 30secs to 300secs, but the zero bytes download problem remains
  • Right, I may have fixed it. But maybe not.
    I have no real idea what I'm going, and I'm worried about hacking code which is (a) someone else's and (b) not very clear to me as a non-programmer.

    Thanks to Mr.Google, various posts refer to issues of correct values in header('Content-Length: ' not being set, e.g. the following from :-
    http://stackoverflow.com/questions/4706073/php-force-download-causing-0-byte-files
    ===
    According to PHP site, php.net/manual/en/function.readfile.php#102137 header('Content-Length: ' . filesize($file)); $file should really be the full path to the file. Otherwise content length will not always be set, often resulting in the dreaded "0 byte file" problem. Or just try like this header('Content-Length: ' . filesize($filePath)); First set path like this and it immediately worked for me and 0 BYTES problem solved!!!
    ===
    So being brave and having no other options, I hacked download.php and inserted this as a new line after line263.

    $location = $location.$file_name;

    This means download.php now reads :
    263: //Download from filesystem - recommended
    264: $location = $location.$file_name; //new line inserted
    265: if ($fd = fopen ($location, "r"))
    266: {
    267: $fsize = filesize($location);

    which means that :-
    EITHER on line 281 header("Content-length: $fsize"); now reports the correct fie size
    AND/OR on lines 283-286 the following now completes successfully.
    while(!feof($fd)) {
    $buffer = fread($fd, 2048);
    print $buffer;
    }

    I have a suspicion as to why this works, but not really sure.
    It strikes me that either this is a massive bug in the self-host integration, or that there is something non-standard about my set-up which requires for it all to be made specific.
    Not scoring points in any way, just want to understand and be sure it is a robust solution.

    Why do others not have this problem ?
    Does no-one else use the FoxyCart Self-Hosted Downloads, v0.3.1 integration?
    Does nobody else serve files from their own server, using Amazon or Fetchapp for large files?

    Just curious to know and understand, seeing as how it's taken me 6 hours to stumble blindly through this.

    I'm posting this in order to gain confirmation of the approach/hack, and also in case it is helpful to someone else attempting to use the self-hosted option.

    Now I have to test with other files and products

    Tim
  • fc_adamfc_adam FoxyCart Team
    @sparkweb might have some more specific thoughts for you - as he has contributed to that plugin to add in additional features like the S3 integration for example.

    That said, I'm wondering if the script really wants a path to the file from the root rather than relative. I'm not sure why that would be the case - but that might be it?

    Are you seeing any errors in your servers PHP error log - or an error log file within your FTP filesystem?
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Hi Tim,

    I've definitely installed this script several times and in the process have made a number of updates to it. I have wanted to give it a full redevelopment as it is quite awkward in some places, but it's something I haven't gotten around to.

    I know that the regular self-hosted works but most of the sites that use it just use Amazon S3 so that's what I have the most experience setting up.

    Regarding your specific problem, though, it sounds like it might be something unique within your hosting environment because I don't ever recall running into this. That said, the setup is never quite as easy as I think it should be. Seems I'm always running into something.
  • Thanks @fc_adam and @sparkweb

    I was not seeing any errors which is why I had to hack.

    I did try the amazon S3 option and it worked perfectly first time.
    I will use amaxzon s3 if that is my only option.

    However with the hack I made it is now working, subject to final full testing.
    So I'm happy for now.
    Just wanted to share in case others had similar problems.

    Tim
Sign In or Register to comment.