koprogo_api/infrastructure/storage/
storage_provider.rs

1use async_trait::async_trait;
2use uuid::Uuid;
3
4/// Abstraction over the document storage backend.
5#[async_trait]
6pub trait StorageProvider: Send + Sync {
7    /// Persist a file and return the relative path that can later be used to read/delete it.
8    async fn save_file(
9        &self,
10        building_id: Uuid,
11        filename: &str,
12        content: &[u8],
13    ) -> Result<String, String>;
14
15    /// Retrieve the raw bytes and return them as a vector.
16    async fn read_file(&self, relative_path: &str) -> Result<Vec<u8>, String>;
17
18    /// Delete a file if it exists.
19    async fn delete_file(&self, relative_path: &str) -> Result<(), String>;
20
21    /// Check if a file exists in the storage backend.
22    async fn file_exists(&self, relative_path: &str) -> bool;
23}