Commit 7f63bb86 authored by Joe Hoyle's avatar Joe Hoyle
Browse files

Fix seeking so getimagesize() etc will work

parent fb0231d7
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -68,9 +68,12 @@ class CachingEntityBody extends AbstractEntityBodyDecorator

        // You cannot skip ahead past where you've read from the remote stream
        if ($byte > $this->body->getSize()) {
            throw new RuntimeException(
                "Cannot seek to byte {$byte} when the buffered stream only contains {$this->body->getSize()} bytes"
            );
            // Modification by Joe Hoyle, this hack is needed fot getimagesize()
            // to work on the stream
            $this->read( $byte );
            //throw new RuntimeException(
            //    "Cannot seek to byte {$byte} when the buffered stream only contains {$this->body->getSize()} bytes"
            //);
        }

        return $this->body->seek($byte);
+2 −0
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@ class S3_Uploads {
		$this->bucket_hostname = $bucket_hostname ? '//' . $bucket_hostname : 'https://' . strtok( $this->bucket, '/' ) . '.s3.amazonaws.com';

		$this->s3()->registerStreamWrapper();
		stream_context_set_option( stream_context_get_default(), 's3', 'seekable', true );
		stream_context_set_option( stream_context_get_default(), 's3', 'ACL', Aws\S3\Enum\CannedAcl::PUBLIC_READ );
		

	}

	public function filter_upload_dir( $dirs ) {