PHP Class S3_Uploads

显示文件 Open project: humanmade/s3-uploads Class Usage Examples

Public Properties

Property Type Description
$original_upload_dir

Public Methods

Method Description
__construct ( $bucket, $key, $secret, $bucket_url = null, $region = null )
copy_image_from_s3 ( string $file ) : string Get a local copy of the file.
filter_editors ( $editors )
filter_sideload_move_temp_file_to_s3 ( array $file ) : array Copy the file from /tmp to an s3 dir so handle_sideload doesn't fail due to trying to do a rename() on the file cross streams. This is somewhat of a hack to work around the core issue https://core.trac.wordpress.org/ticket/29257
filter_upload_dir ( $dirs )
get_instance ( ) : S3_Uploads
get_original_upload_dir ( )
get_s3_bucket ( ) : string Get the S3 bucket name
get_s3_bucket_region ( )
get_s3_url ( )
register_stream_wrapper ( ) Register the stream wrapper for s3
s3 ( ) : Aws\S3\S3Client
setup ( ) Setup the hooks, urls filtering etc for S3 Uploads
tear_down ( ) Tear down the hooks, url filtering etc for S3 Uploads
wp_filter_delete_file ( string $file_path ) : string When WordPress removes files, it's expecting to do so on absolute file paths, as such it breaks when using uris for file paths (such as s3://.
wp_filter_read_image_metadata ( array $meta, string $file ) : array | boolean Filters wp_read_image_metadata. exif_read_data() doesn't work on file streams so we need to make a temporary local copy to extract exif data from.

Method Details

__construct() public method

public __construct ( $bucket, $key, $secret, $bucket_url = null, $region = null )

copy_image_from_s3() public method

Get a local copy of the file.
public copy_image_from_s3 ( string $file ) : string
$file string
return string

filter_editors() public method

public filter_editors ( $editors )

filter_sideload_move_temp_file_to_s3() public method

Copy the file from /tmp to an s3 dir so handle_sideload doesn't fail due to trying to do a rename() on the file cross streams. This is somewhat of a hack to work around the core issue https://core.trac.wordpress.org/ticket/29257
public filter_sideload_move_temp_file_to_s3 ( array $file ) : array
$file array
return array

filter_upload_dir() public method

public filter_upload_dir ( $dirs )

get_instance() public static method

public static get_instance ( ) : S3_Uploads
return S3_Uploads

get_original_upload_dir() public method

get_s3_bucket() public method

Get the S3 bucket name
public get_s3_bucket ( ) : string
return string

get_s3_bucket_region() public method

get_s3_url() public method

public get_s3_url ( )

register_stream_wrapper() public method

Register the stream wrapper for s3

s3() public method

public s3 ( ) : Aws\S3\S3Client
return Aws\S3\S3Client

setup() public method

Setup the hooks, urls filtering etc for S3 Uploads
public setup ( )

tear_down() public method

Tear down the hooks, url filtering etc for S3 Uploads
public tear_down ( )

wp_filter_delete_file() public method

..). We have to filter the file_path to only return the relative section, to play nice with WordPress handling.
public wp_filter_delete_file ( string $file_path ) : string
$file_path string
return string

wp_filter_read_image_metadata() public method

Filters wp_read_image_metadata. exif_read_data() doesn't work on file streams so we need to make a temporary local copy to extract exif data from.
public wp_filter_read_image_metadata ( array $meta, string $file ) : array | boolean
$meta array
$file string
return array | boolean

Property Details

$original_upload_dir public_oe property

public $original_upload_dir