as3cf->get_setting( 'endpoint' ); if ( ! empty( $endpoint ) ) { $args['endpoint'] = rtrim( $endpoint, '/' ); $args['use_path_style_endpoint'] = true; } return $args; } /** * Returns the host (and port if non-standard) extracted from the configured endpoint URL. * * @return string */ public function get_domain() { $endpoint = $this->as3cf->get_setting( 'endpoint' ); if ( empty( $endpoint ) ) { return ''; } $parsed = parse_url( $endpoint ); $host = isset( $parsed['host'] ) ? $parsed['host'] : ''; if ( ! empty( $parsed['port'] ) ) { $host .= ':' . $parsed['port']; } return $host; } /** * No region-based prefix is needed for S3-compatible services. * * @param string $region * @param null|int $expires * * @return string */ protected function url_prefix( $region = '', $expires = null ) { return ''; } /** * Always use path-style URLs: endpoint-host/bucket instead of bucket.endpoint-host. * * @param string $domain * @param string $bucket * @param string $region * @param int $expires * @param array $args * * @return string */ protected function url_domain( $domain, $bucket, $region = '', $expires = null, $args = array() ) { return $domain . '/' . $bucket; } /** * Create bucket without a LocationConstraint, which many S3-compatible * services do not support. * * @param array $args */ public function create_bucket( array $args ) { // Remove AWS-specific location constraint; S3-compatible services // typically don't support it and use the endpoint region instead. unset( $args['LocationConstraint'] ); parent::create_bucket( $args ); } /** * Block Public Access is not supported by most S3-compatible services. * * @param string $bucket * @param bool $block */ public function block_public_access( string $bucket, bool $block ) { // Not supported — do nothing. } /** * Object Ownership enforcement is not supported by most S3-compatible services. * * @param string $bucket * @param bool $enforce */ public function enforce_object_ownership( string $bucket, bool $enforce ) { // Not supported — do nothing. } /** * Returns the console title (not applicable for generic S3-compatible services). * * @return string */ public static function get_console_title(): string { return _x( 'Console', 'Provider console link text', 'amazon-s3-and-cloudfront' ); } }