• Resolved conducivedata

    (@conducivedata)


    All attachments (PSDs and PDFs tested) downloaded through the plugin are being corrupted somehow. They download fine using the links in the admin interface.

    I fixed / worked around this by doing two things. First, commenting out ob_clean(); at the bottom of function wcpoa_send_file, line 185 in class-woocommerce-product-attachment-public.php . There’s no ob_start() call anywhere in the plugin that I can see, so ob_clean() and ob_end_flush() won’t do anything anyway (except break files, apparently).

    That nearly fixed the files, however when opened with a text editor, they all began with a PHP warning about the filesize stat call failing. According to the PHP manual, using stat on files accessed through https:// is not supported.

    So the second fix was switching the filesize call directly above ob_clean() to use a local file path instead of a URL path. For this I added a $file_path variable with the following line of code: $file_path = get_attached_file($attID);

    Could you please evaluate these bugs and fixes and incorporate them into the next release?

    This is on a server running PHP 7.1 and Apache 2.4 with mod_http2.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dotstore

    (@dots)

    Hello @conducivedata,
    Thank for reporting. Our team will review and resolve plugin issue as soon as possible.

    Thank you.

    @dots
    i am also facing same problem.
    do let me know when you make plugin update.
    or else give me work around.

    Plugin Author Dotstore

    (@dots)

    Hello @sonaltle,
    Thanks for reaching out to us. We resolve this issue and we will release new version soon.

    I appreciate your patience.

    cexpert

    (@cexpert)

    I am also experiencing corrupted file errors for All PDFs attachments downloads but for the link in the product management in the admin interface.

    I tried editing the class-woocommerce-product-attachment-public.php file like conducivedata said but it didn’t work for me.
    It has been a month now that this problem was reported and I just downloaded the plugin a few days ago. Is there any chance we can see this problem resolved soon?

    Kind regards,
    Claude LaBadie

    Plugin Author Dotstore

    (@dots)

    Hello @cexpert,

    Thanks for contacting us. I assume that the issue on your hosting server side you can ask server provider set “server configuration by allow_url_fopen=1” now this functionality is disabled so file can’t read and not download properly.

    If you need any help then kindly let me know.

    Thank You,
    DotStore.

    Thread Starter conducivedata

    (@conducivedata)

    @cexpert Below is my modified wcpoa_send_file function. The fixes listed above were not super clear, I realize.

    I just did a before and after test with a clean install of v1.0.8 of the plugin, making no other changes than the few lines in this function, and it went from broken to working.

    
        public function wcpoa_send_file() {
            //get filedata
            if (isset($_GET['attachment_id'])) {
    
                $attID = $_GET['attachment_id'];
                $theFile = wp_get_attachment_url($attID);
    	        if (!$theFile) {
    		        return;
    	        }
    	        //clean the fileurl
    	        $file_url = stripslashes(trim($theFile));
    	        //get filename
    	        $file_name = basename($theFile);
    	        //get fileextension
                    $file_path = get_attached_file($attID);
    
    	        $file_extension = pathinfo($file_name);
    	        //security check
    	        $fileName = strtolower($file_url);
    	        //print_r($file_url);
    	        $file_new_name = $file_name;
    	        $content_type = "";
    	        //check filetype
    	        switch ($file_extension['extension']) {
    		        case "png":
    			        $content_type = "image/png";
    			        break;
    		        case "gif":
    			        $content_type = "image/gif";
    			        break;
    		        case "tiff":
    			        $content_type = "image/tiff";
    			        break;
    		        case "jpeg":
    		        case "jpg":
    			        $content_type = "image/jpg";
    			        break;
    		        case "pdf":
    			        $content_type = "application/pdf";
    			        break;
    		        default:
    			        $content_type = "application/force-download";
    	        }
    
    	        $content_type = apply_filters("wcpoa_content_type", $content_type, $file_extension['extension']);
    
    	        header('Content-Description: File Transfer');
    	        header('Content-Type: application/octet-stream');
    	        header("Content-Type: {$content_type}");
    	        header("Content-Disposition: attachment; filename={$file_new_name}");
    	        header("Content-Transfer-Encoding: Binary");
    	        header('Connection: Keep-Alive');
    	        header('Expires: 0');
    	        header("Cache-Control: no-cache, no-store, must-revalidate");
    	        header('Cache-Control: pre-check=0, post-check=0, max-age=0', false);
    	        header("Pragma: public");
    	        header('Content-Length: ' . filesize($file_path));
    //	        ob_clean();
    	        flush();
    	        readfile($file_url);
    //	        ob_end_flush();
    	        exit();
            }
        }
    
    thomasbeyer

    (@thomasbeyer)

    I have the same problem, but dont know much about coding… Heres an example: https://www.fuglesangs.no/produkt/274-avfettingsmiddel-for-industrien-20l/
    under “Datablader” is it supposed to be a Product Sheet and Safety Data Sheet to download in PDF, but instead theres a page with symbols and text…

    Plugin Author Dotstore

    (@dots)

    Hi @thomasbeyer,
    Sorry dor the inconvenience with the plugins. You Can please update the new latest version, I hope issue has been resolved if you still getting issue then create support ticket on our support panel and provide you’re details so our team will happy to assist you.
    Support Panel: https://store.multidots.com/dotstore-support/

    Thank You,
    Multidots.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Corrupted Downloads’ is closed to new replies.