Commit ab1bba9e authored by Joe Hoyle's avatar Joe Hoyle
Browse files

Add stream wrapper subclass so we can have a non-implemented chmod() function...

Add stream wrapper subclass so we can have a non-implemented chmod() function to stop warnings when they aren't needed
parent c7647316
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
<?php

class S3_Uploads_Stream_Wrapper extends Aws\S3\StreamWrapper {

	/**
	 * Register the 's3://' stream wrapper
	 *
	 * @param S3Client $client Client to use with the stream wrapper
	 */
	public static function register( Aws\S3\S3Client $client)
	{
		if (in_array('s3', stream_get_wrappers())) {
			stream_wrapper_unregister('s3');
		}

		stream_wrapper_register('s3', __CLASS__, STREAM_IS_URL);
		static::$client = $client;
	}

	public function stream_metadata( $path, $option, $value ) {
		// not implemented
	}
}
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ class S3_Uploads {
			require_once dirname( __FILE__ ) . '/class-s3-uploads-local-stream-wrapper.php';
			stream_wrapper_register( 's3', 'S3_Uploads_Local_Stream_Wrapper', STREAM_IS_URL );
		} else {
			$this->s3()->registerStreamWrapper();
			$s3 = $this->s3();
			S3_Uploads_Stream_Wrapper::register( $s3 );
		}

		stream_context_set_option( stream_context_get_default(), 's3', 'seekable', true );
@@ -80,6 +81,7 @@ class S3_Uploads {
	public function s3() {

		require_once dirname( __FILE__ ) . '/aws-sdk/aws-autoloader.php';
		require_once dirname( __FILE__ ) . '/class-s3-uploads-stream-wrapper.php';

		if ( ! empty( $this->s3 ) )
			return $this->s3;