Commit 66caab7b authored by zscott's avatar zscott
Browse files

Added config define()s for default Expires and Cache-Control HTTP headers

S3_UPLOADS_EXPIRES and S3_UPLOADS_CACHE_CONTROL
parent 033b186b
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -20,6 +20,22 @@ class S3_Uploads_Stream_Wrapper extends Aws\S3\StreamWrapper {
	// Override
	public function stream_flush() {

		// Add some HTTP headers which can be defined in wp-config.php

		// Expires:
		if ( defined( 'S3_UPLOADS_EXPIRES' ) ) {
			$this->params[ 'Expires' ] = S3_UPLOADS_EXPIRES;
		}

		// Cache-Control:
		if ( defined( 'S3_UPLOADS_CACHE_CONTROL' ) ) {
			if ( is_numeric( S3_UPLOADS_CACHE_CONTROL ) ) {
				$this->params[ 'CacheControl' ] = 'max-age='. S3_UPLOADS_CACHE_CONTROL;
			} else {
				$this->params[ 'CacheControl' ] = S3_UPLOADS_CACHE_CONTROL;
			}
		}

		// Theses are the parameters passed to S3Client::putObject()
		// http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.S3.S3Client.html#_putObject
		$this->params = apply_filters( 's3_uploads_putObject_params', $this->params );