Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-36917

PDF Download is not running on Android Web Browser.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.3.3
    • Fix Version/s: None
    • Component/s: Libraries, Resource
    • Labels:
    • Database:
      Any
    • Testing Instructions:
      Hide

      In any resource configuration (Force Download, embed, in pop-up, ...)
      Use a Android web browser to enter into a course and try to download any type of resource PDF. After try to download the result is a corrupt PDF.

      And its the same in Android web browser 4.0

      Show
      In any resource configuration (Force Download, embed, in pop-up, ...) Use a Android web browser to enter into a course and try to download any type of resource PDF. After try to download the result is a corrupt PDF. And its the same in Android web browser 4.0
    • Workaround:
      Hide

      In php file: /lib/filelib.php
      function send_stored_file
      Around lines: 2353
      Description: I solved the problem changing the mimetype for android web browser. It's a bug of android web browser but with this patch we can fix it. I force all resource on android to download and there get the correct app.
      Original Code :

      // Use given MIME type if specified, otherwise guess it using mimeinfo.
      // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
      // only Firefox saves all files locally before opening when content-disposition: attachment stated
          $filename     = is_null($filename) ? $stored_file->get_filename() : $filename;
          $isFF         = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested
          $mimetype     = ($forcedownload and !$isFF) ? 'application/x-forcedownload' :
                               ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
       
          // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup

      Modified Code:

      // Use given MIME type if specified, otherwise guess it using mimeinfo.
      // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
      // only Firefox saves all files locally before opening when content-disposition: attachment stated
          $filename     = is_null($filename) ? $stored_file->get_filename() : $filename;
          $isFF         = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested
          $mimetype     = ($forcedownload and !$isFF) ? 'application/x-forcedownload' :
                               ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
      $isANDROID    = check_browser_version('WebKit Android'); //Android web browser
      if($isANDROID) $mimetype = ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
      if($isANDROID) $forcedownload = true; // Force download to any type of resource configuration. 
          
      // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
      ...

      Show
      In php file: /lib/filelib.php function send_stored_file Around lines: 2353 Description: I solved the problem changing the mimetype for android web browser. It's a bug of android web browser but with this patch we can fix it. I force all resource on android to download and there get the correct app. Original Code : // Use given MIME type if specified, otherwise guess it using mimeinfo. // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O // only Firefox saves all files locally before opening when content-disposition: attachment stated $filename = is_null($filename) ? $stored_file->get_filename() : $filename; $isFF = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested $mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));   // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup Modified Code: // Use given MIME type if specified, otherwise guess it using mimeinfo. // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O // only Firefox saves all files locally before opening when content-disposition: attachment stated $filename = is_null($filename) ? $stored_file->get_filename() : $filename; $isFF = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested $mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename)); $isANDROID = check_browser_version('WebKit Android'); //Android web browser if($isANDROID) $mimetype = ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename)); if($isANDROID) $forcedownload = true; // Force download to any type of resource configuration. // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup ...
    • Affected Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-36917-master

      Description

      Can not view PDF documents on Android Device.
      Any PDF resource is not currently working on Android versions 2.3

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              phalacee Jason Fowler
              Reporter:
              dcastro David Castro
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: