Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 53 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions objectstore-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ publish = false
[dependencies]
anyhow = { workspace = true }
argh = "0.1.13"
axum = "0.8.4"
axum-extra = "0.10.1"
async-stream = "0.3.6"
axum = { version = "0.8.4", features = ["multipart"] }
axum-extra = { version = "0.12.2", features = ["multipart"] }
bytes = { workspace = true }
console = "0.16.1"
elegant-departure = { version = "0.3.2", features = ["tokio"] }
figment = { version = "0.10.19", features = ["env", "test", "yaml"] }
futures = { workspace = true }
futures-util = { workspace = true }
http = { workspace = true }
humantime = { workspace = true }
humantime-serde = { workspace = true }
jsonwebtoken = { workspace = true }
merni = { workspace = true }
mimalloc = { workspace = true }
mime = "0.3.17"
multer = "3.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@lcian lcian Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I think we can use axum::extract::Multipart directly now.
With the old design, which included a manifest of operations as the first part, the correct content-type would've been multipart/mixed and therefore I had to use multer (which axum::extract::Multipart uses under the hood) directly because axum::extract::Multipart only works with multipart/form-data 😅.
Now multipart/form-data is correct, so we can move to using axum::extract::Multipart directly.

num_cpus = "1.17.0"
objectstore-service = { workspace = true }
objectstore-types = { workspace = true }
Expand Down
11 changes: 4 additions & 7 deletions objectstore-server/src/auth/service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use objectstore_service::id::{ObjectContext, ObjectId};
use objectstore_service::{PayloadStream, StorageService};
use objectstore_service::{DeleteResult, GetResult, InsertResult, PayloadStream, StorageService};
use objectstore_types::{Metadata, Permission};

use crate::auth::AuthContext;
Expand Down Expand Up @@ -55,24 +55,21 @@ impl AuthAwareService {
key: Option<String>,
metadata: &Metadata,
stream: PayloadStream,
) -> anyhow::Result<ObjectId> {
) -> InsertResult {
self.assert_authorized(Permission::ObjectWrite, &context)?;
self.service
.insert_object(context, key, metadata, stream)
.await
}

/// Auth-aware wrapper around [`StorageService::get_object`].
pub async fn get_object(
&self,
id: &ObjectId,
) -> anyhow::Result<Option<(Metadata, PayloadStream)>> {
pub async fn get_object(&self, id: &ObjectId) -> GetResult {
self.assert_authorized(Permission::ObjectRead, id.context())?;
self.service.get_object(id).await
}

/// Auth-aware wrapper around [`StorageService::delete_object`].
pub async fn delete_object(&self, id: &ObjectId) -> anyhow::Result<()> {
pub async fn delete_object(&self, id: &ObjectId) -> DeleteResult {
self.assert_authorized(Permission::ObjectDelete, id.context())?;
self.service.delete_object(id).await
}
Expand Down
22 changes: 22 additions & 0 deletions objectstore-server/src/endpoints/batch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use axum::Router;
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use axum::routing;
use objectstore_service::id::ObjectContext;

use crate::auth::AuthAwareService;
use crate::endpoints::common::ApiResult;
use crate::extractors::{BatchRequest, Xt};
use crate::state::ServiceState;

pub fn router() -> Router<ServiceState> {
Router::new().route("/objects:batch/{usecase}/{scopes}/", routing::post(batch))
}

async fn batch(
_service: AuthAwareService,
Xt(_context): Xt<ObjectContext>,
_request: BatchRequest,
) -> ApiResult<Response> {
Ok(StatusCode::NOT_IMPLEMENTED.into_response())
}
1 change: 1 addition & 0 deletions objectstore-server/src/endpoints/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};

#[derive(Debug)]
pub enum AnyhowResponse {
Error(anyhow::Error),
Response(Response),
Expand Down
5 changes: 4 additions & 1 deletion objectstore-server/src/endpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ use axum::Router;

use crate::state::ServiceState;

mod batch;
mod common;
mod health;
mod objects;

pub fn routes() -> Router<ServiceState> {
let routes_v1 = Router::new().merge(objects::router());
let routes_v1 = Router::new()
.merge(objects::router())
.merge(batch::router());

Router::new()
.merge(health::router())
Expand Down
Loading