pub struct FileActionHandler { /* private fields */ }
Expand description
Handler for file action operations
Provides methods for specialized file operations that are separate from basic file CRUD operations.
Implementations§
Source§impl FileActionHandler
impl FileActionHandler
Sourcepub fn new(client: FilesClient) -> Self
pub fn new(client: FilesClient) -> Self
Sourcepub async fn begin_upload(
&self,
path: &str,
size: Option<i64>,
mkdir_parents: bool,
) -> Result<Vec<FileUploadPartEntity>>
pub async fn begin_upload( &self, path: &str, size: Option<i64>, mkdir_parents: bool, ) -> Result<Vec<FileUploadPartEntity>>
Begin file upload (Stage 1 of upload process)
This must be called before uploading any file. It returns upload URLs and parameters needed to perform the actual upload.
§Arguments
path
- Destination path for the filesize
- Total size of file in bytes (optional)mkdir_parents
- Create parent directories if they don’t exist
§Returns
Returns a vector of FileUploadPartEntity
containing upload URLs and parameters.
For small files, this will typically be a single element. For large files,
it may contain multiple parts for parallel upload.
§Examples
use files_sdk::{FilesClient, FileActionHandler};
let client = FilesClient::builder()
.api_key("your-api-key")
.build()?;
let handler = FileActionHandler::new(client);
// Begin upload for a 1KB file
let upload_info = handler
.begin_upload("/uploads/test.txt", Some(1024), true)
.await?;
println!("Upload URL: {:?}", upload_info[0].upload_uri);
Sourcepub async fn begin_multipart_upload(
&self,
path: &str,
size: i64,
parts: i32,
mkdir_parents: bool,
) -> Result<Vec<FileUploadPartEntity>>
pub async fn begin_multipart_upload( &self, path: &str, size: i64, parts: i32, mkdir_parents: bool, ) -> Result<Vec<FileUploadPartEntity>>
Begin multi-part upload for large files
For files larger than the default part size, this allows requesting multiple upload parts for parallel uploading.
§Arguments
path
- Destination path for the filesize
- Total size of file in bytesparts
- Number of parts to split the upload intomkdir_parents
- Create parent directories if they don’t exist
§Returns
Returns a vector of FileUploadPartEntity
, one for each part
Sourcepub async fn get_metadata(&self, path: &str) -> Result<FileEntity>
pub async fn get_metadata(&self, path: &str) -> Result<FileEntity>
Get file metadata without downloading
This is useful when you want file information without generating download URLs or logging download activity.
§Arguments
path
- File path
§Examples
let handler = FileActionHandler::new(client);
let metadata = handler.get_metadata("/path/to/file.txt").await?;
println!("Size: {:?}", metadata.size);
Trait Implementations§
Source§impl Clone for FileActionHandler
impl Clone for FileActionHandler
Source§fn clone(&self) -> FileActionHandler
fn clone(&self) -> FileActionHandler
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more