File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -545,13 +545,25 @@ public static function inputFile($file, $md5sum = true)
545545 * @param string $md5sum MD5 hash to send (optional)
546546 * @return array | false
547547 */
548- public static function inputResource (&$ resource , $ bufferSize , $ md5sum = '' )
548+ public static function inputResource (&$ resource , $ bufferSize = false , $ md5sum = '' )
549549 {
550- if (!is_resource ($ resource ) || $ bufferSize < 0 )
550+ if (!is_resource ($ resource ) || ( int ) $ bufferSize < 0 )
551551 {
552552 self ::__triggerError ('S3::inputResource(): Invalid resource or buffer size ' , __FILE__ , __LINE__ );
553553 return false ;
554554 }
555+
556+ // Try to figure out the bytesize
557+ if ($ bufferSize === false )
558+ {
559+ if (fseek ($ resource , 0 , SEEK_END ) < 0 || ($ bufferSize = ftell ($ resource )) === false )
560+ {
561+ self ::__triggerError ('S3::inputResource(): Unable to obtain resource size ' , __FILE__ , __LINE__ );
562+ return false ;
563+ }
564+ fseek ($ resource , 0 );
565+ }
566+
555567 $ input = array ('size ' => $ bufferSize , 'md5sum ' => $ md5sum );
556568 $ input ['fp ' ] =& $ resource ;
557569 return $ input ;
You can’t perform that action at this time.
0 commit comments