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

PDF Download is not running on Android Web Browser.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • None
    • 2.3.3
    • Libraries, Resource
    • Any
    • MOODLE_23_STABLE
    • wip-MDL-36917-master
    • 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 ...
    • 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

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

            phalacee Jason Fowler
            dcastro David Castro (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.