Storage

Struct Storage 

Source
pub struct Storage { /* private fields */ }

Implementations§

Source§

impl Storage

Source

pub fn new(client: &Client) -> Self

Source

pub fn list_buckets( &self, search: Option<&str>, limit: Option<i64>, offset: Option<i64>, cursor: Option<&str>, cursor_direction: Option<&str>, order_type: Option<&str>, ) -> Result<BucketList, AppwriteException>

Get a list of all the storage buckets. You can use the query params to filter your results.

Source

pub fn create_bucket( &self, bucket_id: &str, name: &str, permission: &str, read: Option<&[&str]>, write: Option<&[&str]>, enabled: Option<bool>, maximum_file_size: Option<i64>, allowed_file_extensions: Option<&[&str]>, encryption: Option<bool>, antivirus: Option<bool>, ) -> Result<Bucket, AppwriteException>

Create a new storage bucket.

Source

pub fn get_bucket(&self, bucket_id: &str) -> Result<Bucket, AppwriteException>

Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata.

Source

pub fn update_bucket( &self, bucket_id: &str, name: &str, permission: &str, read: Option<&[&str]>, write: Option<&[&str]>, enabled: Option<bool>, maximum_file_size: Option<i64>, allowed_file_extensions: Option<&[&str]>, encryption: Option<bool>, antivirus: Option<bool>, ) -> Result<Bucket, AppwriteException>

Update a storage bucket by its unique ID.

Source

pub fn delete_bucket(&self, bucket_id: &str) -> Result<Value, AppwriteException>

Delete a storage bucket by its unique ID.

Source

pub fn list_files( &self, bucket_id: &str, search: Option<&str>, limit: Option<i64>, offset: Option<i64>, cursor: Option<&str>, cursor_direction: Option<&str>, order_type: Option<&str>, ) -> Result<FileList, AppwriteException>

Get a list of all the user files. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project’s files. Learn more about different API modes.

Source

pub fn create_file( &self, bucket_id: &str, file_id: &str, file: PathBuf, read: Option<&[&str]>, write: Option<&[&str]>, ) -> Result<File, AppwriteException>

Create a new file. Before using this route, you should create a new bucket resource using either a server integration API or directly from your Appwrite console.

Larger files should be uploaded using multiple requests with the content-range header to send a partial request with a maximum supported chunk of 5MB. The content-range header values should always be in bytes.

When the first request is sent, the server will return the File object, and the subsequent part request must include the file’s id in x-appwrite-id header to allow the server to know that the partial upload is for the existing file and not for a new one.

If you’re creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally.

Source

pub fn get_file( &self, bucket_id: &str, file_id: &str, ) -> Result<File, AppwriteException>

Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.

Source

pub fn update_file( &self, bucket_id: &str, file_id: &str, read: Option<&[&str]>, write: Option<&[&str]>, ) -> Result<File, AppwriteException>

Update a file by its unique ID. Only users with write permissions have access to update this resource.

Source

pub fn delete_file( &self, bucket_id: &str, file_id: &str, ) -> Result<Value, AppwriteException>

Delete a file by its unique ID. Only users with write permissions have access to delete this resource.

Source

pub fn get_file_download( &self, bucket_id: &str, file_id: &str, ) -> Result<Vec<u8>, AppwriteException>

Get a file content by its unique ID. The endpoint response return with a ‘Content-Disposition: attachment’ header that tells the browser to start downloading the file to user downloads directory.

Source

pub fn get_file_preview( &self, bucket_id: &str, file_id: &str, width: Option<i64>, height: Option<i64>, gravity: Option<&str>, quality: Option<i64>, border_width: Option<i64>, border_color: Option<&str>, border_radius: Option<i64>, opacity: Option<f64>, rotation: Option<i64>, background: Option<&str>, output: Option<&str>, ) -> Result<Vec<u8>, AppwriteException>

Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.

Source

pub fn get_file_view( &self, bucket_id: &str, file_id: &str, ) -> Result<Vec<u8>, AppwriteException>

Get a file content by its unique ID. This endpoint is similar to the download method but returns with no ‘Content-Disposition: attachment’ header.

Source

pub fn get_usage( &self, range: Option<&str>, ) -> Result<UsageStorage, AppwriteException>

Source

pub fn get_bucket_usage( &self, bucket_id: &str, range: Option<&str>, ) -> Result<UsageBuckets, AppwriteException>

Trait Implementations§

Source§

impl Clone for Storage

Source§

fn clone(&self) -> Storage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,