diff --git a/crates/artifact/src/lib.rs b/crates/artifact/src/lib.rs index 12aab33..ab6143d 100644 --- a/crates/artifact/src/lib.rs +++ b/crates/artifact/src/lib.rs @@ -30,8 +30,8 @@ use core_types::{PrivateArtifact, PublicArtifact}; use self::methods::*; -const ARTIFACT_PRIVATE_LTS_BUCKET: &str = "picturepro-artifact-private-lts"; -const ARTIFACT_PUBLIC_LTS_BUCKET: &str = "picturepro-artifact-public-lts"; +const ARTIFACT_PRIVATE_LTS_BUCKET: &str = "picturepro-private"; +const ARTIFACT_PUBLIC_LTS_BUCKET: &str = "picturepro-public"; type ObjectStoreGenerator = Box Result> + Send + 'static>; @@ -89,12 +89,10 @@ impl Artifact for PublicArtifact { Self::new_with_id(id, contents) } fn new_with_id(id: Self::Id, contents: Option) -> Self { - let url = format!( - "https://s3.{}.amazonaws.com/{}/{}", - std::env::var("AWS_DEFAULT_REGION").unwrap(), - ARTIFACT_PUBLIC_LTS_BUCKET, - id.0 - ); + let url = + format!("https://{}.jlewis.sh/{}", ARTIFACT_PUBLIC_LTS_BUCKET, id.0); + tracing::info!("public artifact url: {}", url); + Self { id, url, diff --git a/crates/artifact/src/methods.rs b/crates/artifact/src/methods.rs index 4136662..2750da2 100644 --- a/crates/artifact/src/methods.rs +++ b/crates/artifact/src/methods.rs @@ -6,12 +6,28 @@ use crate::ObjectStoreGenerator; pub fn object_store_from_env( bucket_name: &str, ) -> Result> { - let object_store = object_store::aws::AmazonS3Builder::from_env() - .with_region( - std::env::var("AWS_DEFAULT_REGION") - .wrap_err("Failed to get AWS region from environment")?, - ) + let endpoint = format!( + "https://{}.r2.cloudflarestorage.com", + std::env::var("R2_ACCOUNT") + .wrap_err("Failed to get R2 account from environment")? + ); + tracing::info!("endpoint: {}", endpoint); + + let object_store = object_store::aws::AmazonS3Builder::new() + // .with_region( + // std::env::var("AWS_DEFAULT_REGION") + // .wrap_err("Failed to get AWS region from environment")?, + // ) + .with_endpoint(endpoint) .with_bucket_name(bucket_name) + .with_access_key_id( + std::env::var("AWS_ACCESS_KEY_ID") + .wrap_err("Failed to get AWS access key ID from environment")?, + ) + .with_secret_access_key( + std::env::var("AWS_SECRET_ACCESS_KEY") + .wrap_err("Failed to get AWS secret access key from environment")?, + ) .build() .wrap_err("Failed to create object store")?; diff --git a/crates/bl/src/upload/mod.rs b/crates/bl/src/upload/mod.rs index 875f2c9..7875562 100644 --- a/crates/bl/src/upload/mod.rs +++ b/crates/bl/src/upload/mod.rs @@ -45,7 +45,7 @@ pub enum PhotoUploadError { custom = RmpEncoded, output = Json, )] -#[cfg_attr(feature = "ssr", tracing::instrument)] +#[cfg_attr(feature = "ssr", tracing::instrument(skip(params)))] pub async fn upload_photo_group( params: PhotoGroupUploadParams, ) -> Result> { @@ -180,10 +180,12 @@ async fn create_photo( let original_upload_task = tokio::spawn({ let original_artifact = original_artifact.clone(); async move { - original_artifact + let result = original_artifact .upload_and_push() .await - .wrap_err("Failed to create original artifact") + .wrap_err("Failed to create original artifact"); + tracing::info!("original artifact: {:?}", result); + result } });