pub struct Builder {
pub url: Url,
pub headers: HeaderMap,
pub client: Client,
pub method: Method,
pub body: Option<BodyType>,
}
Fieldsยง
ยงurl: Url
ยงheaders: HeaderMap
ยงclient: Client
ยงmethod: Method
ยงbody: Option<BodyType>
Implementationsยง
Sourceยงimpl Builder
impl Builder
Sourcepub fn get_buckets(self) -> Executor
pub fn get_buckets(self) -> Executor
retrieve all buckets
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.get_buckets()
.execute();
Sourcepub fn create_bucket(self, body: &str) -> Executor
pub fn create_bucket(self, body: &str) -> Executor
create a new bucket
ยงArguments
body
- The request body as a string.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.create_bucket("thefux")
.execute();
Sourcepub fn create_bucket_from(self, body: NewBucket) -> Executor
pub fn create_bucket_from(self, body: NewBucket) -> Executor
create a new bucket using a struct
ยงArguments
body
- TheNewBucket
struct containing the request body.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.create_bucket_from(NewBucket::new("thefux".to_string()))
.execute();
Sourcepub fn empty_bucket(self, bucket_id: &str) -> Executor
pub fn empty_bucket(self, bucket_id: &str) -> Executor
empty the bucket
ยงArguments
bucket_id
- The identifier of the bucket to empty.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.empty_bucket("thefux")
.execute();
Sourcepub fn get_bucket_details(self, bucket_id: &str) -> Executor
pub fn get_bucket_details(self, bucket_id: &str) -> Executor
get bucket details
ยงArguments
bucket_id
- The identifier of the bucket to empty.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.get_bucket_details("thefux")
.execute();
Sourcepub fn update_bucket(self, bucket_id: &str, body: &str) -> Executor
pub fn update_bucket(self, bucket_id: &str, body: &str) -> Executor
update the bucket
ยงArguments
bucket_id
- The identifier of the bucket to empty.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.update_bucket("thefux", r#"{ "public": true }"#)
.execute();
Sourcepub fn update_bucket_from(self, bucket_id: &str, body: BucketUpdate) -> Executor
pub fn update_bucket_from(self, bucket_id: &str, body: BucketUpdate) -> Executor
update bucket using a struct
ยงArguments
bucket_id
- The identifier of the bucket to empty.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::BucketUpdate,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.update_bucket_from("thefux", BucketUpdate {
public: false,
file_size_limit: Some(0),
allowed_mime_types: Some(vec!["application/pdf".to_string()]),
})
.execute();
Sourcepub fn delete_bucket(self, bucket_id: &str) -> Executor
pub fn delete_bucket(self, bucket_id: &str) -> Executor
delete a bucket
ยงArguments
bucket_id
- The identifier of the bucket to empty.
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
};
use dotenv::dotenv;
dotenv().ok();
let config = SupabaseConfig::default();
let storage = Storage::new_with_config(config)
.from()
.delete_bucket("thefux")
.execute();
Sourceยงimpl Builder
impl Builder
Sourcepub fn new(url: Url, headers: HeaderMap, client: Client) -> Self
pub fn new(url: Url, headers: HeaderMap, client: Client) -> Self
Creates a new Builder
instance.
ยงArguments
url
- The URL for the request.headers
- TheHeaderMap
containing the headers for the request.client
- TheClient
to use for making the request.
ยงExample
use supabase_storage::build::builder::Builder;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::Client;
use url::Url;
let url = Url::parse("http://localhost").unwrap();
let builder = Builder::new(url, HeaderMap::new(), Client::new());
Sourcepub fn build(self) -> RequestBuilder
pub fn build(self) -> RequestBuilder
Constructs and returns a RequestBuilder
instance based on the current Builder
configuration.
ยงReturns
RequestBuilder
- The constructedRequestBuilder
instance.
Sourcepub fn header(self, key: impl IntoHeaderName, value: HeaderValue) -> Self
pub fn header(self, key: impl IntoHeaderName, value: HeaderValue) -> Self
Adds a new header to the request.
ยงArguments
key
- The header name, implementors ofIntoHeaderName
are accepted.value
- The header value as a string.
ยงReturns
Self
- The updatedBuilder
instance with the new header added.
ยงExample
use supabase_storage::build::builder::Builder;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::Client;
use url::Url;
let url = Url::parse("http://localhost").unwrap();
let _ = Builder::new(url, HeaderMap::new(), Client::new())
.header("Authorization", HeaderValue::from_static("Bearer <token>"));
Sourcepub async fn run(self) -> Result<Response, Error>
pub async fn run(self) -> Result<Response, Error>
Executes the constructed HTTP request and returns the response as a Result
.
ยงReturns
Result<Response, Error>
- The result of the executed request.
ยงExample
use supabase_storage::build::builder::Builder;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::Client;
use url::Url;
#[tokio::main]
async fn main() {
let url = Url::parse("http://localhost").unwrap();
let mut headers = HeaderMap::new();
headers.insert("Authorization", HeaderValue::from_static("Bearer YOUR_ACCESS_TOKEN"));
let builder = Builder::new(url, headers, Client::new())
.header("Authorization", HeaderValue::from_static("Bearer <token>"));
// Execute the request and handle the response
let response = builder.run().await;
match response {
Ok(response) => {
let body = response.text().await.unwrap();
println!("Response body: {:?}", body);
}
Err(error) => {
eprintln!("Error occurred: {:?}", error);
}
}
}
Sourcepub fn create_executor(self) -> Executor
pub fn create_executor(self) -> Executor
Creates a new Executor
instance based on the current Builder
configuration.
ยงReturns
Executor
- The createdExecutor
instance.
Sourceยงimpl Builder
impl Builder
Sourcepub fn list_objects(self, bucket_id: &str, body: &str) -> Executor
pub fn list_objects(self, bucket_id: &str, body: &str) -> Executor
list all files within a bucket
ยงArguments
bucket_id
- bucket idbody
- request body
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.list_objects("thefux", r#"
{
"prefix": "bitcoin.pdf",
"limit": 100,
"offset": 0,
"sortBy": {
"column": "name",
"order": "asc",
},
}"#)
.execute()
.await
.unwrap();
}
Sourceยงimpl Builder
impl Builder
Sourcepub fn move_object(self, bucket_id: &str, from: &str, to: &str) -> Executor
pub fn move_object(self, bucket_id: &str, from: &str, to: &str) -> Executor
move an object
ยงArguments
bucket_id
- bucket idfrom
- object soruceto
- object destination
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.move_object("thefux", "from", "to")
.execute()
.await
.unwrap();
}
Sourcepub fn move_object_from(self, obj: MoveCopyObject) -> Executor
pub fn move_object_from(self, obj: MoveCopyObject) -> Executor
move an object
ยงArguments
bucket_id
- bucket idfrom
- object soruceto
- object destination
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
model::object::MoveCopyObject,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let move_obj = MoveCopyObject {
bucket_id: "thefux".to_string(),
source_key: "from".to_string(),
destination_key: "to".to_string(),
};
let response = Storage::new_with_config(config)
.from()
.move_object_from(move_obj)
.execute()
.await
.unwrap();
}
Sourcepub fn copy_object(self, bucket_id: &str, from: &str, to: &str) -> Executor
pub fn copy_object(self, bucket_id: &str, from: &str, to: &str) -> Executor
copy an object
ยงArguments
bucket_id
- bucket idfrom
- object soruceto
- object destination
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.copy_object("thefux", "from", "to")
.execute()
.await
.unwrap();
}
Sourcepub fn copy_object_from(self, obj: MoveCopyObject) -> Executor
pub fn copy_object_from(self, obj: MoveCopyObject) -> Executor
copy an object
ยงArguments
bucket_id
- bucket idfrom
- object soruceto
- object destination
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
model::object::MoveCopyObject,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let move_obj = MoveCopyObject {
bucket_id: "thefux".to_string(),
source_key: "from".to_string(),
destination_key: "to".to_string(),
};
let response = Storage::new_with_config(config)
.from()
.copy_object_from(move_obj)
.execute()
.await
.unwrap();
}
Sourceยงimpl Builder
impl Builder
Sourcepub fn get_public_object(self, bucket_id: &str, object: &str) -> Executor
pub fn get_public_object(self, bucket_id: &str, object: &str) -> Executor
get public object from the storage
ยงArguments
bucket_id
- bucket idobject
- a wildcard
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.get_public_object("thefux", "file_name.pdf")
.execute()
.await
.unwrap();
}
Sourcepub fn get_public_object_info(self, bucket_id: &str, object: &str) -> Executor
pub fn get_public_object_info(self, bucket_id: &str, object: &str) -> Executor
get public object info
ยงArguments
bucket_id
- bucket idobject
- a wildcard
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.get_public_object_info("thefux", "file_name.pdf")
.execute()
.await
.unwrap();
}
Sourceยงimpl Builder
impl Builder
Sourcepub fn get_object_with_transform(
self,
bucket_id: &str,
object: &str,
transform: Transform,
) -> Executor
pub fn get_object_with_transform( self, bucket_id: &str, object: &str, transform: Transform, ) -> Executor
get public object from the storage
ยงArguments
bucket_id
- bucket idobject
- object name/pathtransform
- tranformation options to transform before serving it to client
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
model::options::{Transform, Format, Resize}
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.get_object_with_transform("thefux", "test.png", Transform {
format: Some(Format::Origin),
height: Some(0),
quality: Some(0),
resize: Some(Resize::Cover),
width: Some(0),
})
.execute()
.await
.unwrap();
}
Sourceยงimpl Builder
impl Builder
Sourcepub fn create_signed_url(
self,
bucket_name: &str,
object: &str,
body: &str,
) -> Executor
pub fn create_signed_url( self, bucket_name: &str, object: &str, body: &str, ) -> Executor
generate presigned url to retrieve an object
ยงArguments
bucket_name
- bucket nameobject
- object name
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.create_signed_url("thefux", "bitcoin.pdf", r#"
{
"expiresIn": 3600,
"transform": {
"height": 0,
"width": 0,
"resize": "cover",
"format": "origin",
"quality": 100
}
}"#)
.execute()
.await
.unwrap();
}
Sourcepub fn create_signed_urls(self, bucket_name: &str, body: &str) -> Executor
pub fn create_signed_urls(self, bucket_name: &str, body: &str) -> Executor
generate presigned urls to retrieve objects
ยงArguments
bucket_name
- bucket nameobject
- object name
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.create_signed_urls("thefux", r#"{"expiresIn": 3600, "paths": ["hello.pdf", "test.pdf"]}"#)
.execute()
.await
.unwrap();
}
Sourcepub fn get_object_with_pre_assigned_url(
self,
bucket_name: &str,
object: &str,
token: &str,
) -> Executor
pub fn get_object_with_pre_assigned_url( self, bucket_name: &str, object: &str, token: &str, ) -> Executor
get object via pre-signed url
ยงArguments
bucket_name
- bucket nameobject
- object nametoken
- sign tokenfile
- file object
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
use tokio::fs::File;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.get_object_with_pre_assigned_url("thefux", "btc.pdf", "<token>")
.execute()
.await
.unwrap();
}
Sourceยงimpl Builder
impl Builder
Sourcepub fn create_signed_upload_url(self, bucket_id: &str, object: &str) -> Executor
pub fn create_signed_upload_url(self, bucket_id: &str, object: &str) -> Executor
generate pre-signed url to upload an object
ยงArguments
bucket_id
- bucket idobject
- object name
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.create_signed_upload_url("thefux", "bitcoin.pdf")
.execute()
.await
.unwrap();
}
Sourcepub async fn upload_to_signed_url_async(
self,
bucket_id: &str,
object: &str,
token: &str,
file_path: &str,
file_options: FileOptions,
) -> Executor
pub async fn upload_to_signed_url_async( self, bucket_id: &str, object: &str, token: &str, file_path: &str, file_options: FileOptions, ) -> Executor
upload object via pre-signed url
ยงArguments
bucket_id
- bucket idobject
- object nametoken
- sign tokenfile_path
- file pathfile_options
- file options
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
model::options::FileOptions,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.upload_to_signed_url_async("thefux", "btc.pdf", "<token>", "out/test.pdf", FileOptions {
cache_control: None,
content_type: Some("application/pdf".to_string()),
upsert: Some(true),
})
.await
.execute()
.await
.unwrap();
}
Sourcepub async fn upload_to_signed_url_no_options_async(
self,
bucket_id: &str,
object: &str,
token: &str,
file_path: &str,
) -> Executor
pub async fn upload_to_signed_url_no_options_async( self, bucket_id: &str, object: &str, token: &str, file_path: &str, ) -> Executor
upload object via pre-signed url with auto detecting content-type
ยงArguments
bucket_id
- bucket idobject
- object nametoken
- sign tokenfile_path
- file path
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.upload_to_signed_url_no_options_async("thefux", "btc.pdf", "<token>", "out/test.pdf")
.await
.execute()
.await
.unwrap();
}
Sourcepub fn upload_from_file_with_pre_assigned_url(
self,
bucket_id: &str,
object: &str,
token: &str,
file: File,
file_options: FileOptions,
) -> Executor
pub fn upload_from_file_with_pre_assigned_url( self, bucket_id: &str, object: &str, token: &str, file: File, file_options: FileOptions, ) -> Executor
upload object via pre-signed url
ยงArguments
bucket_id
- bucket idobject
- object nametoken
- sign tokenfile
- file object
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
model::options::FileOptions,
};
use dotenv::dotenv;
use tokio::fs::File;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.upload_from_file_with_pre_assigned_url("thefux", "btc.pdf", "<token>",
File::open("out/test.pdf").await.unwrap(),
FileOptions {
cache_control: None,
content_type: None,
upsert: None,
})
.execute()
.await
.unwrap();
}
Sourceยงimpl Builder
impl Builder
Sourcepub fn delete_object(self, bucket_id: &str, object: &str) -> Executor
pub fn delete_object(self, bucket_id: &str, object: &str) -> Executor
delete an object, could be any kind of data stored in the given storage
ยงArguments
bucket_id
- bucket idobject
- a wildcard
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.delete_object("thefux", "file_name.pdf")
.execute()
.await
.unwrap();
}
Sourcepub fn delete_objects(self, bucket_id: &str, body: &str) -> Executor
pub fn delete_objects(self, bucket_id: &str, body: &str) -> Executor
delete multiple objects
ยงArguments
bucket_id
- bucket idbody
- json object with list of perfixes
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.delete_objects("thefux", r#"{ "prefixes" : [ "file_name.pdf" ]}"#)
.execute()
.await
.unwrap();
}
Sourcepub fn get_object(self, bucket_name: &str, object: &str) -> Executor
pub fn get_object(self, bucket_name: &str, object: &str) -> Executor
get an object from the storage
ยงArguments
bucket_name
- bucket nameobject
- a wildcard
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.delete_object("thefux", "file_name.pdf")
.execute()
.await
.unwrap();
}
Examples found in repository?
6async fn main() {
7 dotenv().ok();
8
9 let config = SupabaseConfig::default();
10 let storage = Storage::new_with_config(config);
11
12 let bucket_name = "thefux";
13 let object = "btc.pdf";
14
15 let response = storage
16 .from()
17 .get_object(bucket_name, object)
18 .execute()
19 .await
20 .unwrap();
21
22 println!("{:?}", response);
23}
Sourcepub async fn update_object_async(
self,
bucket_name: &str,
object: &str,
file_path: &str,
) -> Executor
pub async fn update_object_async( self, bucket_name: &str, object: &str, file_path: &str, ) -> Executor
update an object
ยงArguments
bucket_name
- bucket nameobject
- a wildcard
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.update_object_async("thefux", "file_name.pdf", "out/test.pdf")
.await
.execute()
.await
.unwrap();
}
Sourcepub async fn upload_object(
self,
bucket_name: &str,
object: &str,
file_path: &str,
) -> Executor
pub async fn upload_object( self, bucket_name: &str, object: &str, file_path: &str, ) -> Executor
upload an object
ยงArguments
bucket_name
- bucket nameobject
- object name
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.upload_object("thefux", "file_name.pdf", "out/test.pdf")
.await
.execute()
.await
.unwrap();
}
Sourcepub fn download_object(self, bucket_id: &str) -> Executor
pub fn download_object(self, bucket_id: &str) -> Executor
download object
ยงArguments
bucket_id
- bucket idbody
- request body
ยงReturns
Executor
- The constructedExecutor
instance for executing the request.
ยงExample
use supabase_storage::{
Storage,
config::SupabaseConfig,
model::bucket::NewBucket,
};
use dotenv::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
let config = SupabaseConfig::default();
let response = Storage::new_with_config(config)
.from()
.download_object("thefux")
.execute()
.await
.unwrap();
}