diff --git a/backend/windmill-api/src/job_helpers_oss.rs b/backend/windmill-api/src/job_helpers_oss.rs index 53d4a796a1..2f00462075 100644 --- a/backend/windmill-api/src/job_helpers_oss.rs +++ b/backend/windmill-api/src/job_helpers_oss.rs @@ -134,3 +134,13 @@ pub async fn download_s3_file_internal( "Not implemented in Windmill's Open Source repository".to_string(), )) } + +#[cfg(not(feature = "private"))] +pub async fn read_object_streamable( + s3_client: Arc, + file_key: &str, +) -> anyhow::Result { + Err(error::Error::internal_err( + "Not implemented in Windmill's Open Source repository".to_string(), + )) +} diff --git a/backend/windmill-api/src/s3_proxy.rs b/backend/windmill-api/src/s3_proxy.rs index 90de126187..baaa6d752e 100644 --- a/backend/windmill-api/src/s3_proxy.rs +++ b/backend/windmill-api/src/s3_proxy.rs @@ -17,17 +17,23 @@ use crate::{ }; pub fn workspaced_unauthed_service() -> Router { - Router::new().route("/:storage/:key", get(get_object)) + Router::new().route("/*key", get(get_object)) } async fn get_object( Extension(db): Extension, - Path((w_id, storage, file_key)): Path<(String, String, String)>, + Path((w_id, full_key)): Path<(String, String)>, ) -> Result { + let full_key = full_key.strip_prefix("s3://").unwrap_or(&full_key); + let Some((storage, object_key)) = full_key.split_once('/').map(|(s, k)| (s, k)) else { + return Err(Error::InternalErr( + "Invalid S3 key : no storage".to_string(), + )); + }; let storage = if storage.is_empty() { None } else { - Some(storage) + Some(storage.to_string()) }; // temp values @@ -46,7 +52,7 @@ async fn get_object( "No files storage resource defined at the workspace level".to_string(), ))?; let s3_client = build_object_store_client(&s3_resource).await?; - let result = read_object_streamable(s3_client, &file_key).await?; + let result = read_object_streamable(s3_client, object_key).await?; let stream = result.into_stream(); let stream_body = axum::body::Body::from_stream(stream); Ok(stream_body.into_response())