pub struct UploadBlobStreamParams<'a> {
pub upload_url_template: &'a JmapUrlTemplate,
pub account_id: &'a Id,
pub content_type: &'a str,
pub body: BlobUploadBody,
pub content_length: Option<u64>,
}Expand description
Parameters for JmapClient::upload_blob_stream.
The streaming counterpart of UploadBlobParams: body replaces the
in-memory data, and content_length states the body length when it
is known in advance.
let file = tokio::fs::File::open("video.mp4").await?;
let len = file.metadata().await?.len();
client.upload_blob_stream(UploadBlobStreamParams {
upload_url_template: &session.upload_url,
account_id: &Id::from("A13824"),
content_type: "video/mp4",
body: upload_body_from_reader(file),
content_length: Some(len),
}).await?;Fields§
§upload_url_template: &'a JmapUrlTemplateURL template from Session.upload_url. {accountId} is the only
template variable substituted before the POST request.
account_id: &'a IdAccount ID that will own the uploaded blob; substituted for
{accountId} in the URL template.
content_type: &'a strMedia type sent as the HTTP Content-Type request header. Must
be a valid HTTP header value or upload fails with
ClientError::InvalidHeaderValue.
body: BlobUploadBodyThe bytes to upload. Their SHA-256 and length are computed as they
are sent and cross-checked against the server’s
BlobUploadResponse.sha256 (when present) and size, exactly as
JmapClient::upload_blob does.
content_length: Option<u64>Exact byte length of body, when known. Some(n) is sent as
Content-Length: n; None sends the body with chunked
transfer coding (RFC 9112 §7.1). If body yields a different
number of bytes than Some(n) states, the upload fails with
ClientError::Http.