[−][src]Struct cloud_storage_rs::Bucket
Represents a Bucket in Google Cloud Storage that can be used to upload, download or move files
Methods
impl Bucket[src]
pub fn existing(name: &str) -> Self[src]
Returns a Bucket struct with the corresponding name. If the bucket does not exist, an attempt to store or retrieve files will always fail.
let bucket = Bucket::existing("my-companies-production-bucket");
pub fn create(name: &str) -> Result<Self, Error>[src]
Creates a new Bucket resource on Goolges server, then returns a struct representing this Bucket.
let bucket = Bucket::create("my-companies-staging-bucket").unwrap();
pub fn upload(
&self,
file: &[u8],
filename: &str,
mime_type: &str
) -> Result<(), Error>[src]
&self,
file: &[u8],
filename: &str,
mime_type: &str
) -> Result<(), Error>
Upload a file as that is loaded in memory to google cloud storage, where it will be interpreted according to the mime type you specified.
let bucket = Bucket::existing("cat-photos"); let file: Vec<u8> = read_cute_cat("cat.png"); bucket.upload(&file, "recently read cat.png", "image/png").expect("cat not uploaded");
pub fn update(&self, old_name: &str, new_name: &str) -> Result<(), Error>[src]
Allows renaming a file. Note that since a files name is its full path, you can use the renaming capacities to move files as well
let bucket = Bucket::existing("cat-photos"); bucket.update("recently read cat.png", "cuties/old cat.png").expect("cat not moved");
pub fn delete(&self, name: &str) -> Result<(), Error>[src]
Removes a file from the Bucket. Depending on your content retention policy, this may very well be permanent!
let bucket = Bucket::existing("cat-photos"); bucket.delete("dog.jpg").expect("wrong animal not removed");
pub fn download_url(&self, file_path: &str, duration: u32) -> String[src]
Generates a signed url that is valid for duration seconds, that lets anyone read the file
without further authentication. Note that this function returns a String, so generating
the signed url will never fail. If the file does not exist, or the service account has no
access to the file, then the signed url will result in a 404 or a 401.
let bucket = Bucket::existing("cat-photos"); bucket.download_url("cuties/old cat.png");
Auto Trait Implementations
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnwindSafe for Bucket
impl RefUnwindSafe for Bucket
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,