pub struct FilesResource { /* private fields */ }
Expand description
Resource for managing files via the Anthropic Files API
Implementations§
Source§impl FilesResource
impl FilesResource
Sourcepub fn new(http_client: Arc<HttpClient>) -> Self
pub fn new(http_client: Arc<HttpClient>) -> Self
Create a new files resource
Sourcepub async fn upload(&self, params: FileUploadParams) -> Result<FileObject>
pub async fn upload(&self, params: FileUploadParams) -> Result<FileObject>
Sourcepub async fn upload_with_progress<F>(
&self,
params: FileUploadParams,
progress_callback: F,
) -> Result<FileObject>where
F: FnMut(UploadProgress),
pub async fn upload_with_progress<F>(
&self,
params: FileUploadParams,
progress_callback: F,
) -> Result<FileObject>where
F: FnMut(UploadProgress),
Sourcepub async fn get(&self, file_id: &str) -> Result<FileObject>
pub async fn get(&self, file_id: &str) -> Result<FileObject>
Sourcepub async fn download(&self, file_id: &str) -> Result<FileDownload>
pub async fn download(&self, file_id: &str) -> Result<FileDownload>
Sourcepub async fn delete(&self, file_id: &str) -> Result<FileObject>
pub async fn delete(&self, file_id: &str) -> Result<FileObject>
Sourcepub async fn get_storage_info(&self) -> Result<StorageInfo>
pub async fn get_storage_info(&self) -> Result<StorageInfo>
Sourcepub async fn wait_for_processing(
&self,
file_id: &str,
poll_interval: Option<Duration>,
timeout: Option<Duration>,
) -> Result<FileObject>
pub async fn wait_for_processing( &self, file_id: &str, poll_interval: Option<Duration>, timeout: Option<Duration>, ) -> Result<FileObject>
Wait for a file to be processed
§Arguments
file_id
- The ID of the file to wait forpoll_interval
- How often to check the status (default: 2 seconds)timeout
- Maximum time to wait (default: 5 minutes)
§Returns
The processed FileObject
§Errors
Returns an error if the file processing fails or times out
Source§impl FilesResource
High-level file management utilities
impl FilesResource
High-level file management utilities
Sourcepub async fn upload_batch(
&self,
uploads: Vec<FileUploadParams>,
max_concurrent: Option<usize>,
) -> Result<Vec<FileObject>>
pub async fn upload_batch( &self, uploads: Vec<FileUploadParams>, max_concurrent: Option<usize>, ) -> Result<Vec<FileObject>>
Sourcepub async fn cleanup_old_files(&self, max_age: Duration) -> Result<u32>
pub async fn cleanup_old_files(&self, max_age: Duration) -> Result<u32>
Sourcepub async fn get_files_by_purpose(
&self,
purpose: FilePurpose,
limit: Option<u32>,
) -> Result<Vec<FileObject>>
pub async fn get_files_by_purpose( &self, purpose: FilePurpose, limit: Option<u32>, ) -> Result<Vec<FileObject>>
Trait Implementations§
Source§impl Clone for FilesResource
impl Clone for FilesResource
Source§fn clone(&self) -> FilesResource
fn clone(&self) -> FilesResource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for FilesResource
impl !RefUnwindSafe for FilesResource
impl Send for FilesResource
impl Sync for FilesResource
impl Unpin for FilesResource
impl !UnwindSafe for FilesResource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more