1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 XF 1.3.4 serving corrupted image attachments

Discussion in 'Troubleshooting and Problems' started by Eldar Shamukhamedov, Aug 18, 2014.

  1. Hello fellow XenForo'ers ('uns?),

    I have recently upgrade from 1.1.3 to 1.3.4 and am still working out a lot of small bugs. In the process, I encountered this oddity:

    When a user uploads an image file attachment, if the file is a PNG or JPEG, the stored file (in AWS S3 internal_data in my case) differs slightly from the served file (via XenForo_ViewPublic_Attachment_View::renderRaw()):
    http://www.diffnow.com/?report=8r9mn

    The result is corrupted:
    http://imgur.com/HDX8hv7

    I am using Zend_Service_Amazon_S3 (version: S3.php 24593 2012-01-05 20:35:02Z) to write/read from AWS.

    Any thoughts or pointers? Any help would be appreciated. :)


    Edit:
    Here's a var_dump of the response and params:
    Code:
    ["_response":protected]=>
      object(Zend_Controller_Response_Http)#29 (8) {
        ["_body":protected]=>
        array(0) {
        }
        ["_exceptions":protected]=>
        array(0) {
        }
        ["_headers":protected]=>
        array(7) {
          [0]=>
          array(3) {
            ["name"]=>
            string(15) "X-Frame-Options"
            ["value"]=>
            string(10) "SAMEORIGIN"
            ["replace"]=>
            bool(false)
          }
          [1]=>
          array(3) {
            ["name"]=>
            string(13) "Last-Modified"
            ["value"]=>
            string(29) "Mon, 18 Aug 2014 06:27:55 GMT"
            ["replace"]=>
            bool(true)
          }
          [2]=>
          array(3) {
            ["name"]=>
            string(12) "Content-Type"
            ["value"]=>
            string(10) "image/jpeg"
            ["replace"]=>
            bool(true)
          }
          [3]=>
          array(3) {
            ["name"]=>
            string(19) "Content-Disposition"
            ["value"]=>
            string(32) "inline; filename="wherewolf.jpg""
            ["replace"]=>
            bool(true)
          }
          [4]=>
          array(3) {
            ["name"]=>
            string(4) "Etag"
            ["value"]=>
            string(12) ""1408337496""
            ["replace"]=>
            bool(true)
          }
          [5]=>
          array(3) {
            ["name"]=>
            string(14) "Content-Length"
            ["value"]=>
            string(5) "28947"
            ["replace"]=>
            bool(true)
          }
          [6]=>
          array(3) {
            ["name"]=>
            string(22) "X-Content-Type-Options"
            ["value"]=>
            string(7) "nosniff"
            ["replace"]=>
            bool(false)
          }
        }
        ["_headersRaw":protected]=>
        array(0) {
        }
        ["_httpResponseCode":protected]=>
        int(200)
        ["_isRedirect":protected]=>
        bool(false)
        ["_renderExceptions":protected]=>
        bool(false)
        ["headersSentThrowsException"]=>
        bool(true)
      }
    
    ["_params":protected]=>
      array(2) {
        ["attachment"]=>
        array(15) {
          ["attachment_id"]=>
          int(167315)
          ["data_id"]=>
          int(168277)
          ["content_type"]=>
          string(4) "post"
          ["content_id"]=>
          int(496571638)
          ["attach_date"]=>
          int(1408337496)
          ["temp_hash"]=>
          string(0) ""
          ["unassociated"]=>
          int(0)
          ["view_count"]=>
          int(0)
          ["filename"]=>
          string(13) "wherewolf.jpg"
          ["file_size"]=>
          int(28947)
          ["file_hash"]=>
          string(32) "84a4f8f5eea9b9a23902d1822db96ee3"
          ["width"]=>
          int(500)
          ["height"]=>
          int(622)
          ["thumbnail_width"]=>
          int(96)
          ["thumbnail_height"]=>
          int(119)
        }
        ["attachmentFile"]=>
        string(105) "s3://---.------.------.com/internal_data/attachments/168/168277-84a4f8f5eea9b9a23902d1822db96ee3.data"
      }
    
     
    Last edited: Aug 18, 2014
  2. After more digging, readfile() and file_get_contents() on an s3:// file path turned out to be the culprit:

    PHP:
    <?
    require_once 
    'Zend/Service/Amazon/S3.php';
    $s3 = new Zend_Service_Amazon_S3('-- key --''-- aws secret --');
    $s3->registerStreamWrapper("s3");
    $fgetData   file_get_contents('s3://'.$filePath);
    $zendS3Data $s3->getObject($filePath);

    echo (
    $fgetData === $zendS3Data); // -> bool(false);
    ?>
    Pardon the n00b thread. Hopefully this will help someone out one day!
     

Share This Page