Commit 80f1fc7e authored by Joe Hoyle's avatar Joe Hoyle
Browse files

Store the path on s3 without a leading /

parent 8ba1f1d9
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ class S3_Uploads_WordPress_Uploads_Uploader extends S3_Uploads_Uploader {
		if ( ! file_exists( $file ) || strpos( $file, WP_CONTENT_DIR ) !== 0 )
			return $file;

		$relative = str_replace( WP_CONTENT_DIR, '', $file );
		$relative = str_replace( WP_CONTENT_DIR . '/', '', $file );

		$response = wp_remote_head( $this->get_s3_url() .'/'. $relative );

@@ -103,7 +103,7 @@ class S3_Uploads_WordPress_Uploads_Uploader extends S3_Uploads_Uploader {
		if ( ! $path = get_post_meta( $attachment_id, 's3_path', true ) )
			return $url;

		return $this->get_s3_url() . $path;
		return $this->get_s3_url() . '/' . $path;
	}

	/**
@@ -124,4 +124,8 @@ class S3_Uploads_WordPress_Uploads_Uploader extends S3_Uploads_Uploader {
			}
		}
	}

	public function is_attachment_uploaded( $attachment_id ) {
		return (bool) get_post_meta( $attachment_id, 's3_path', true );
	}
}