fix(zip): stream ZIP to temp file instead of loading entire archive into RAM
Solution C - Hybrid temp-file streaming: - ZipPort trait now returns NamedTempFile instead of Vec<u8> - ZipService writes to a temp file via ZipWriter<std::fs::File> (O(1) RAM) - Files are read in 64KB stream chunks via get_file_stream() instead of get_file_content() - HTTP response streams the temp file via ReaderStream (never loads full ZIP in memory) - Temp file auto-deleted on drop after response completes - Removed dead imports (HeaderName, HeaderValue, Cursor, Read)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
use crate::common::errors::DomainError;
|
||||
use async_trait::async_trait;
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
/// Port for ZIP archive operations.
|
||||
///
|
||||
@@ -15,10 +16,11 @@ use async_trait::async_trait;
|
||||
pub trait ZipPort: Send + Sync + 'static {
|
||||
/// Create a ZIP archive containing the contents of a folder (recursively).
|
||||
///
|
||||
/// Returns the ZIP file bytes.
|
||||
/// Returns a temporary file containing the ZIP archive. The caller streams
|
||||
/// it to the client and the file is automatically deleted when dropped.
|
||||
async fn create_folder_zip(
|
||||
&self,
|
||||
folder_id: &str,
|
||||
folder_name: &str,
|
||||
) -> Result<Vec<u8>, DomainError>;
|
||||
) -> Result<NamedTempFile, DomainError>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user