Issues

ZF-11435: Zend_Http_Client method setRawData - fstat fails on remove file pointers

Issue Type: Bug Created: 2011-06-03T15:38:56.000+0000 Last Updated: 2011-06-03T15:38:56.000+0000 Status: Open Fix version(s): Reporter: Greg Greenhaw (greggreenhaw) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Client

  • Zend_Service_Amazon

Related issues: Attachments:

Description

public function setRawData($data, $enctype = null) { $this->raw_post_data = $data; $this->setEncType($enctype); if (is_resource($data)) { // We've got stream data $stat = @fstat($data); if($stat) { $this->setHeaders(self::CONTENT_LENGTH, $stat['size']); } } return $this; }

When passing in a file pointer to a remote file via Zend_Service_Amazon_S3 putFileStream method the fstat fails in the above method causing a content length required error from amazon. Maybe a method this this should be used instead:

/** * Return the size in bytes of a local or remote file * * @param string $file - path to file * @return int */ public static function getFileSize($path) { if(substr($path,0,4) != 'http') return @filesize($path);

    $x = array_change_key_case(get_headers($path, 1),CASE_LOWER); 

    $length = null;

    if(is_array($x['content-length']))
        $length = $x['content-length'][count($x['content-length']) - 1];
    else
        $length = $x['content-length'];

    if(empty($length))
        $length = @filesize($path); 

    return (int) $length;   
}

Comments

No comments to display

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts