pub struct Object {
Show 31 fields pub kind: String, pub id: String, pub self_link: String, pub name: String, pub bucket: String, pub generation: i64, pub metageneration: i64, pub content_type: Option<String>, pub time_created: DateTime<Utc>, pub updated: DateTime<Utc>, pub time_deleted: Option<DateTime<Utc>>, pub temporary_hold: Option<bool>, pub event_based_hold: Option<bool>, pub retention_expiration_time: Option<DateTime<Utc>>, pub storage_class: String, pub time_storage_class_updated: DateTime<Utc>, pub size: u64, pub md5_hash: Option<String>, pub media_link: String, pub content_encoding: Option<String>, pub content_disposition: Option<String>, pub content_language: Option<String>, pub cache_control: Option<String>, pub metadata: Option<HashMap<String, String>>, pub acl: Option<Vec<ObjectAccessControl>>, pub owner: Option<Owner>, pub crc32c: String, pub component_count: Option<i32>, pub etag: String, pub customer_encryption: Option<CustomerEncrypton>, pub kms_key_name: Option<String>,
}
Expand description

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§

source§

impl Object

source

pub fn download_url(&self, duration: u32) -> Result<String>

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::{Client, object::{Object, ComposeRequest}};

let client = Client::default();
let obj1 = client.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.
source

pub fn download_url_with( &self, duration: u32, opts: DownloadOptions ) -> Result<String>

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::{Client, object::{Object, ComposeRequest}};

let client = Client::default();
let obj1 = client.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.
source

pub fn upload_url(&self, duration: u32) -> Result<String>

Creates a Signed Url which is valid for duration seconds, and lets the posessor upload data to a blob without any authentication.

Example
use cloud_storage::{Client, object::{Object, ComposeRequest}};

let client = Client::default();
let obj1 = client.object().read("my_bucket", "file1").await?;
let url = obj1.upload_url(50)?;
// url is now a url to which an unauthenticated user can make a PUT request to upload a file
// for 50 seconds.
source

pub fn upload_url_with( &self, duration: u32, custom_metadata: HashMap<String, String> ) -> Result<(String, HashMap<String, String>)>

Creates a Signed Url which is valid for duration seconds, and lets the posessor upload data and custom metadata to a blob without any authentication.

Example
use cloud_storage::{Client, object::{Object, ComposeRequest}};
use std::collections::HashMap;

let client = Client::default();
let obj1 = client.object().read("my_bucket", "file1").await?;
let mut custom_metadata = HashMap::new();
custom_metadata.insert(String::from("field"), String::from("value"));
let (url, headers) = obj1.upload_url_with(50, custom_metadata)?;
// url is now a url to which an unauthenticated user can make a PUT request to upload a file
// for 50 seconds. Note that the user must also include the returned headers in the PUT request

Trait Implementations§

source§

impl Debug for Object

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Object

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Object

source§

fn eq(&self, other: &Object) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Object

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Object

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,