[−][src]Struct cloud_storage::Object
A resource representing a file in Google Cloud Storage.
Fields
kind: String
The kind of item this is. For objects, this is always storage#object
.
id: String
The ID of the object, including the bucket name, object name, and generation number.
self_link: String
The link to this object.
name: String
The name of the object. Required if not specified by URL parameter.
bucket: String
The name of the bucket containing this object.
generation: i64
The content generation of this object. Used for object versioning.
metageneration: i64
The version of the metadata for this object at this generation. Used for preconditions and for detecting changes in metadata. A metageneration number is only meaningful in the context of a particular generation of a particular object.
content_type: Option<String>
Content-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream.
time_created: DateTime<Utc>
The creation time of the object in RFC 3339 format.
updated: DateTime<Utc>
The modification time of the object metadata in RFC 3339 format.
time_deleted: Option<DateTime<Utc>>
The deletion time of the object in RFC 3339 format. Returned if and only if this version of the object is no longer a live version, but remains in the bucket as a noncurrent version.
temporary_hold: Option<bool>
Whether or not the object is subject to a temporary hold.
event_based_hold: Option<bool>
Whether or not the object is subject to an event-based hold.
retention_expiration_time: Option<DateTime<Utc>>
The earliest time that the object can be deleted, based on a bucket's retention policy, in RFC 3339 format.
storage_class: String
Storage class of the object.
time_storage_class_updated: DateTime<Utc>
The time at which the object's storage class was last changed. When the object is initially created, it will be set to timeCreated.
size: u64
Content-Length of the data in bytes.
md5_hash: Option<String>
MD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Hashes and ETags: Best Practices.
media_link: String
Media download link.
content_encoding: Option<String>
Content-Encoding of the object data.
content_disposition: Option<String>
Content-Disposition of the object data.
content_language: Option<String>
Content-Language of the object data.
cache_control: Option<String>
Cache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be public, max-age=3600.
metadata: Option<HashMap<String, String>>
User-provided metadata, in key/value pairs.
acl: Option<Vec<ObjectAccessControl>>
Access controls on the object, containing one or more objectAccessControls Resources. If iamConfiguration.uniformBucketLevelAccess.enabled is set to true, this field is omitted in responses, and requests that specify this field fail.
owner: Option<Owner>
The owner of the object. This will always be the uploader of the object. If
iamConfiguration.uniformBucketLevelAccess.enabled
is set to true, this field does not
apply, and is omitted in responses.
crc32c: String
CRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 in big-endian byte order. For more information about using the CRC32c checksum, see Hashes and ETags: Best Practices.
component_count: Option<i32>
Number of underlying components that make up a composite object. Components are accumulated by compose operations, counting 1 for each non-composite source object and componentCount for each composite source object. Note: componentCount is included in the metadata for composite objects only.
etag: String
HTTP 1.1 Entity tag for the object.
customer_encryption: Option<CustomerEncrypton>
Metadata of customer-supplied encryption key, if the object is encrypted by such a key.
kms_key_name: Option<String>
Cloud KMS Key used to encrypt this object, if the object is encrypted by such a key.
Implementations
impl Object
[src]
pub async fn create<'_, '_, '_>(
bucket: &'_ str,
file: Vec<u8>,
filename: &'_ str,
mime_type: &'_ str
) -> Result<Self>
[src]
bucket: &'_ str,
file: Vec<u8>,
filename: &'_ str,
mime_type: &'_ str
) -> Result<Self>
Create a new object. 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.
Example
use cloud_storage::Object; let file: Vec<u8> = read_cute_cat("cat.png"); Object::create("cat-photos", &file, "recently read cat.png", "image/png").await?;
pub fn create_sync(
bucket: &str,
file: Vec<u8>,
filename: &str,
mime_type: &str
) -> Result<Self>
[src]
bucket: &str,
file: Vec<u8>,
filename: &str,
mime_type: &str
) -> Result<Self>
The synchronous equivalent of Object::create
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn create_streamed<S, '_, '_, '_>(
bucket: &'_ str,
stream: S,
length: u64,
filename: &'_ str,
mime_type: &'_ str
) -> Result<Self> where
S: TryStream + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>>,
Bytes: From<S::Ok>,
[src]
bucket: &'_ str,
stream: S,
length: u64,
filename: &'_ str,
mime_type: &'_ str
) -> Result<Self> where
S: TryStream + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>>,
Bytes: From<S::Ok>,
Create a new object. This works in the same way as Object::create
, except it does not need
to load the entire file in ram.
Example
use cloud_storage::Object; let file = reqwest::Client::new() .get("https://my_domain.rs/nice_cat_photo.png") .send() .await? .bytes_stream(); Object::create_streamed("cat-photos", file, 10, "recently read cat.png", "image/png").await?;
pub fn create_streamed_sync<R: Read + Send + 'static>(
bucket: &str,
file: R,
length: u64,
filename: &str,
mime_type: &str
) -> Result<Self>
[src]
bucket: &str,
file: R,
length: u64,
filename: &str,
mime_type: &str
) -> Result<Self>
The async equivalent of Object::create_streamed
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn list<'_, '_>(
bucket: &'_ str
) -> Result<impl Stream<Item = Result<Vec<Self>, Error>> + '_, Error>
[src]
bucket: &'_ str
) -> Result<impl Stream<Item = Result<Vec<Self>, Error>> + '_, Error>
Obtain a list of objects within this Bucket.
Example
use cloud_storage::Object; let all_objects = Object::list("my_bucket").await?;
pub fn list_sync(bucket: &str) -> Result<Vec<Self>, Error>
[src]
The async equivalent of Object::list
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn list_prefix<'a>(
bucket: &'a str,
prefix: &'a str
) -> Result<impl Stream<Item = Result<Vec<Self>, Error>> + 'a, Error>
[src]
bucket: &'a str,
prefix: &'a str
) -> Result<impl Stream<Item = Result<Vec<Self>, Error>> + 'a, Error>
Obtain a list of objects by prefix within this Bucket .
Example
use cloud_storage::Object; let all_objects = Object::list_prefix("my_bucket", "prefix/").await?;
pub fn list_prefix_sync(bucket: &str, prefix: &str) -> Result<Vec<Self>, Error>
[src]
The async equivalent of Object::list_prefix
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn read<'_, '_>(bucket: &'_ str, file_name: &'_ str) -> Result<Self>
[src]
Obtains a single object with the specified name in the specified bucket.
Example
use cloud_storage::Object; let object = Object::read("my_bucket", "path/to/my/file.png").await?;
pub fn read_sync(bucket: &str, file_name: &str) -> Result<Self>
[src]
The synchronous equivalent of Object::read
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn download<'_, '_>(
bucket: &'_ str,
file_name: &'_ str
) -> Result<Vec<u8>, Error>
[src]
bucket: &'_ str,
file_name: &'_ str
) -> Result<Vec<u8>, Error>
Download the content of the object with the specified name in the specified bucket.
Example
use cloud_storage::Object; let bytes = Object::download("my_bucket", "path/to/my/file.png").await?;
pub fn download_sync(bucket: &str, file_name: &str) -> Result<Vec<u8>>
[src]
The synchronous equivalent of Object::download
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn download_streamed<'_, '_>(
bucket: &'_ str,
file_name: &'_ str
) -> Result<impl Stream<Item = Result<Vec<u8>>>>
[src]
bucket: &'_ str,
file_name: &'_ str
) -> Result<impl Stream<Item = Result<Vec<u8>>>>
Download the content of the object with the specified name in the specified bucket, without allocating the whole file into a vector.
Example
use cloud_storage::Object}; use futures::StreamExt; use std::fs::File; use std::io::Write; let mut stream = Object::download_streamed("my_bucket", "path/to/my/file.png").await?; let mut file = File::create("file.png").unwrap(); for part in stream.next().await { file.write_all(&part.unwrap()).unwrap(); }
pub async fn update<'_>(&'_ self) -> Result<Self>
[src]
Obtains a single object with the specified name in the specified bucket.
Example
use cloud_storage::Object; let mut object = Object::read("my_bucket", "path/to/my/file.png").await?; object.content_type = Some("application/xml".to_string()); object.update().await?;
pub fn update_sync(&self) -> Result<Self>
[src]
The synchronous equivalent of Object::download
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn delete<'_, '_>(
bucket: &'_ str,
file_name: &'_ str
) -> Result<(), Error>
[src]
bucket: &'_ str,
file_name: &'_ str
) -> Result<(), Error>
Deletes a single object with the specified name in the specified bucket.
Example
use cloud_storage::Object; Object::delete("my_bucket", "path/to/my/file.png").await?;
pub fn delete_sync(bucket: &str, file_name: &str) -> Result<(), Error>
[src]
The synchronous equivalent of Object::delete
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn compose<'_, '_, '_>(
bucket: &'_ str,
req: &'_ ComposeRequest,
destination_object: &'_ str
) -> Result<Self>
[src]
bucket: &'_ str,
req: &'_ ComposeRequest,
destination_object: &'_ str
) -> Result<Self>
Obtains a single object with the specified name in the specified bucket.
Example
use cloud_storage::object::{Object, ComposeRequest, SourceObject}; let obj1 = Object::read("my_bucket", "file1").await?; let obj2 = Object::read("my_bucket", "file2").await?; let compose_request = ComposeRequest { kind: "storage#composeRequest".to_string(), source_objects: vec![ SourceObject { name: obj1.name.clone(), generation: None, object_preconditions: None, }, SourceObject { name: obj2.name.clone(), generation: None, object_preconditions: None, }, ], destination: None, }; let obj3 = Object::compose("my_bucket", &compose_request, "test-concatted-file").await?; // obj3 is now a file with the content of obj1 and obj2 concatted together.
pub fn compose_sync(
bucket: &str,
req: &ComposeRequest,
destination_object: &str
) -> Result<Self>
[src]
bucket: &str,
req: &ComposeRequest,
destination_object: &str
) -> Result<Self>
The synchronous equivalent of Object::compose
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn copy<'_, '_, '_>(
&'_ self,
destination_bucket: &'_ str,
path: &'_ str
) -> Result<Self>
[src]
&'_ self,
destination_bucket: &'_ str,
path: &'_ str
) -> Result<Self>
Copy this object to the target bucket and path
Example
use cloud_storage::object::{Object, ComposeRequest}; let obj1 = Object::read("my_bucket", "file1").await?; let obj2 = obj1.copy("my_other_bucket", "file2").await?; // obj2 is now a copy of obj1.
pub fn copy_sync(&self, destination_bucket: &str, path: &str) -> Result<Self>
[src]
The synchronous equivalent of Object::copy
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub async fn rewrite<'_, '_, '_>(
&'_ self,
destination_bucket: &'_ str,
path: &'_ str
) -> Result<Self>
[src]
&'_ self,
destination_bucket: &'_ str,
path: &'_ str
) -> Result<Self>
Moves a file from the current location to the target bucket and path.
Limitations
This function does not yet support rewriting objects to another
- Geographical Location,
- Encryption,
- Storage class. These limitations mean that for now, the rewrite and the copy methods do the same thing.
Example
use cloud_storage::object::Object; let obj1 = Object::read("my_bucket", "file1").await?; let obj2 = obj1.rewrite("my_other_bucket", "file2").await?; // obj2 is now a copy of obj1.
pub fn rewrite_sync(&self, destination_bucket: &str, path: &str) -> Result<Self>
[src]
The synchronous equivalent of Object::rewrite
.
Features
This function requires that the feature flag sync
is enabled in Cargo.toml
.
pub fn download_url(&self, duration: u32) -> Result<String>
[src]
Creates a Signed Url
which is valid for duration
seconds, and lets the posessor download the file contents
without any authentication.
Example
use cloud_storage::object::{Object, ComposeRequest}; let obj1 = Object::read("my_bucket", "file1").await?; let url = obj1.download_url(50)?; // url is now a url to which an unauthenticated user can make a request to download a file // for 50 seconds.
Trait Implementations
impl Debug for Object
[src]
impl<'de> Deserialize<'de> for Object
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<Object> for Object
[src]
impl Serialize for Object
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Object
[src]
Auto Trait Implementations
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,