Project

General

Profile

Feature #21383 » s3-uploads.diff

Boone Gorges, 2025-01-03 01:34 PM

View differences:

wp-content/plugins/s3-uploads/inc/class-plugin.php
287 287
				'query'  => $parsed['query'] ?? null,
288 288
			];
289 289
		}
290

  
291
		// CAC mod: We are using "path" mode rather than virtual-hosted-style URLs.
292
        if ( strpos( $url, 'https://s3.amazonaws.com/' ) === 0 ) {
293
            $parsed = wp_parse_url( $url );
294

  
295
            $key = str_replace( '/'. $this->get_s3_bucket() . '/', '', $parsed['path'] );
296
            return [
297
                'bucket' => $this->get_s3_bucket(),
298
                'key'    => $key,
299
                'query'  => $parsed['query'] ?? null,
300
            ];
301
        }
302

  
290 303
		$upload_dir = wp_upload_dir();
291 304

  
292 305
		if ( strpos( $url, $upload_dir['baseurl'] ) === false ) {
......
298 311
		if ( ! isset( $parsed['host'] ) || ! isset( $parsed['path'] ) ) {
299 312
			return null;
300 313
		}
314

  
301 315
		return [
302 316
			'bucket' => $parsed['host'],
303 317
			'key'    => ltrim( $parsed['path'], '/' ),
    (1-1/1)