• Resolved WebSprite

    (@contentsprite)


    My store is small and orders are not that frequent so this bug began sometime in the last two months. Woo and all plug ins are up to date. Until recently, all automatically generated download links for customers to use worked fine. The files haven’t changed location. But today the links sent to a customer gave different results. EPUB and MOBI format buttons for this new order and old test orders that worked previously now say “no file defined.” PDFs, however, work like they always did.

    The files are on a server with the full path URLs (example https://mysite.com/directoryoutsidewpcontent/filename.epub) in the file location box. Those URLs, pasted directly into a browser, immediately downloads the file. The download is served with X-Accel-Redirect/X-Sendfile protocol.

    I have this feeling that the issue is recognized mime type? Web searches turn up very little or direct me to how to UPLOAD epub and mobi to my media library which isn’t relevant.

    I’ve read the changelogs for Woo and my theme (X theme) and I’m not experienced enough to spot a fix or tweak that would have deauthorized these file types somehow, or if some setting in functions.php or wp-config has been deprecated and I’m the one locking these types out.

    Any help would be very much appreciated.

    • This topic was modified 5 years, 11 months ago by WebSprite. Reason: clarity
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    I would check using other download methods (not X-Accel-Redirect/X-Sendfile), as you have some interesting things going on, between using epub files and also a folder outside of the normal place where your downloads would be.

    Thread Starter WebSprite

    (@contentsprite)

    Hi, thanks for the suggestion (it didn’t make any difference, but really I do thank you for the attempt). I did solve the issue and here’s the gist of it for some other user wandering in the weeds.

    The issue was indeed the MIME type of epub and mobi. PDF (and the single MP3 on the site) worked fine. They’re registered MIME types in the WP core which I just didn’t think was a coincidence. I had registered EPUB and MOBI through a feature in Media Library Assistant which allowed me to use the file types as downloadable products. For some reason some tweak somewhere in the last 8-10 weeks decided that these file types wouldn’t quite work. They’d still be allowed as products but the generated download link died.

    I disabled that feature in MLA and instead added a function into my function.php to register the MIME types there. And now the same download code that gave “no file defined” error works the way it did up until recently.

    function yourthemehere_custom_upload_mimes( $existing_mimes ) {
    	// Add webm to the list of mime types.
    	$existing_mimes['epub'] = 'application/epub+zip';
    	$existing_mimes['mobi'] = 'application/x-mobipocket-ebook';	
    	
    	// Return the array back to the function with our added mime type.
    	return $existing_mimes;
    }
    add_filter( 'mime_types', 'yourthemehere_custom_upload_mimes' );

    I found the code for the function here: https://andrew.dev/how-to-add-a-new-mime-type-to-wordpress/

    Plugin Support Steve E.a11n

    (@woosteve)

    Automattic Happiness Engineer

    Thanks for the follow up and details on the solution. I hope others will find it helpful if they have similar issues.

    With the above I’ll mark this as resolved. Please feel free to open a new thread if you have any further questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Generated download links suddenly “no file defined” for epub mobi but not pdf’ is closed to new replies.