pub struct HtmlFormData(/* private fields */);
Expand description
HTML Form Data.
https://cloud.google.com/storage/docs/xml-api/post-object-forms
§Example (full)
use cloud_storage_signature::HtmlFormData;
use cloud_storage_signature::PolicyDocumentSigningOptions;
use cloud_storage_signature::SigningKey;
let form_data = HtmlFormData::builder()
.acl("public-read")
.bucket("example-bucket")
.cache_control("max-age=3600")
.content_disposition("attachment")
.content_encoding("gzip")
.content_length(1024)
.content_type("application/octet-stream")
.expires("2022-01-04T00:00:00Z")
.key("example-object")
.success_action_redirect("https://example.com/success")
.success_action_status(201)
.x_goog_custom_time("2022-01-03T00:00:00Z")
.x_goog_meta("reviewer", "jane")
.x_goog_meta("project-manager", "john")
.policy_document_signing_options(PolicyDocumentSigningOptions {
accessible_at: None,
expiration: std::time::SystemTime::now() + std::time::Duration::from_secs(60 * 60),
region: None,
signing_key: SigningKey::service_account(
service_account_client_email.to_string(),
service_account_private_key.to_string(),
),
use_sign_blob: false,
})
.build()
.await?;
assert_eq!(
form_data.into_vec().into_iter().map(|(n, _)| n).collect::<Vec<String>>(),
[
"acl",
"bucket",
"Cache-Control",
"Content-Disposition",
"Content-Encoding",
"Content-Length",
"Content-Type",
"Expires",
"key",
"policy",
"success_action_redirect",
"success_action_status",
"x-goog-algorithm",
"x-goog-credential",
"x-goog-custom-time",
"x-goog-date",
"x-goog-signature",
"x-goog-meta-reviewer",
"x-goog-meta-project-manager",
].into_iter().map(|n| n.to_string()).collect::<Vec<String>>()
);
§Example (minimal)
use cloud_storage_signature::HtmlFormData;
assert_eq!(
HtmlFormData::builder()
.key("object_name1")
.build()
.await?
.into_vec(),
vec![("key".to_string(), "object_name1".to_string())]
);
§Example (policy document minimal)
use cloud_storage_signature::HtmlFormData;
use cloud_storage_signature::PolicyDocumentSigningOptions;
use cloud_storage_signature::SigningKey;
let form_data = HtmlFormData::builder()
.bucket("example-bucket")
.key("example-object")
.policy_document_signing_options(PolicyDocumentSigningOptions {
accessible_at: None,
expiration: std::time::SystemTime::now() + std::time::Duration::from_secs(60 * 60),
region: None,
signing_key: SigningKey::service_account(
service_account_client_email.to_string(),
service_account_private_key.to_string()
),
use_sign_blob: false,
})
.build()
.await?;
assert_eq!(
form_data.into_vec().into_iter().map(|(n, _)| n).collect::<Vec<String>>(),
[
"bucket",
"key",
"policy",
"x-goog-algorithm",
"x-goog-credential",
"x-goog-date",
"x-goog-signature",
].into_iter().map(|n| n.to_string()).collect::<Vec<String>>()
);
Implementations§
Trait Implementations§
source§impl Clone for HtmlFormData
impl Clone for HtmlFormData
source§fn clone(&self) -> HtmlFormData
fn clone(&self) -> HtmlFormData
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for HtmlFormData
impl RefUnwindSafe for HtmlFormData
impl Send for HtmlFormData
impl Sync for HtmlFormData
impl Unpin for HtmlFormData
impl UnwindSafe for HtmlFormData
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more