pub struct PutBuilder { /* private fields */ }Expand description
A put request builder.
§Automatic resumable uploads
Large buffers and paths to regular files use resumable uploads automatically,
recovering from interrupted requests. Open files, streams, readers, and uploads queued through
Session::many do not use resumables. No feature flag is required.
Configure this with Self::resumable_threshold_bytes and crate::ClientBuilder::spool_dir.
Implementations§
Source§impl PutBuilder
impl PutBuilder
Sourcepub fn resumable_threshold_bytes(
self,
threshold: impl Into<Option<u64>>,
) -> Self
pub fn resumable_threshold_bytes( self, threshold: impl Into<Option<u64>>, ) -> Self
Sets the minimum remaining input size for automatic resumable uploads.
Measures remaining bytes before client compression. Inherits the
Usecase threshold unless overridden.
Pass None to disable or zero to include every supported payload.
See PutBuilder for eligibility.
session.put("payload").resumable_threshold_bytes(None).send().await?;Sourcepub fn key(self, key: impl Into<ObjectKey>) -> Self
pub fn key(self, key: impl Into<ObjectKey>) -> Self
Sets an explicit object key.
If a key is specified, the object will be stored under that key. Otherwise, the Objectstore server will automatically assign a random key, which is then returned from this request.
Sourcepub fn compress(self, compression: impl Into<Option<Compression>>) -> Self
pub fn compress(self, compression: impl Into<Option<Compression>>) -> Self
Sets an explicit compression algorithm to be used for this payload.
The client compresses the payload and records the algorithm in the
object’s metadata. None should be used if no compression should be performed by the
client, either because the payload is uncompressible (such as a media format), or if the
compression should not be recorded for this object.
If the payload is already compressed and the algorithm should still be recorded, use
precompressed instead.
By default, the compression algorithm set on this Session’s Usecase is used (see
with_compression).
§Example
session.put(media)
.compress(None) // uncompressible payload
.send()
.await
.unwrap();Sourcepub fn precompressed(self, compression: Compression) -> Self
pub fn precompressed(self, compression: Compression) -> Self
Declares that the payload is already compressed with the given algorithm.
The payload is uploaded verbatim, and the algorithm is recorded in the object’s metadata so that downloads decompress it transparently. Use this to hand pre-compressed data to the client without paying for another compression pass.
This overrides the compression algorithm set on this Session’s Usecase. To have the
client perform the compression instead, use compress.
§Example
session.put(zstd_data)
.precompressed(Compression::Zstd)
.send()
.await
.unwrap();Sourcepub fn expiration_policy(self, expiration_policy: ExpirationPolicy) -> Self
pub fn expiration_policy(self, expiration_policy: ExpirationPolicy) -> Self
Sets the expiration policy of the object to be uploaded.
By default, the expiration policy set on this Session’s Usecase is used.
Sourcepub fn content_type(self, content_type: impl Into<Cow<'static, str>>) -> Self
pub fn content_type(self, content_type: impl Into<Cow<'static, str>>) -> Self
Sets the content type of the object to be uploaded.
You can use the utility function crate::utils::guess_mime_type to attempt to guess a
content_type based on magic bytes.
Sourcepub fn origin(self, origin: impl Into<String>) -> Self
pub fn origin(self, origin: impl Into<String>) -> Self
Sets the origin of the object, typically the IP address of the original source.
This is an optional but encouraged field that tracks where the payload was originally obtained from. For example, the IP address of the Sentry SDK or CLI that uploaded the data.
§Example
session.put("data")
.origin("203.0.113.42")
.send()
.await
.unwrap();Sourcepub fn filename(self, filename: impl Into<String>) -> Self
pub fn filename(self, filename: impl Into<String>) -> Self
Sets the filename of the object.
When present, the server will include a Content-Disposition: attachment; filename="<filename>"
header in GET responses, prompting browsers and download tools to save the file under
this name.
Sourcepub fn set_metadata(self, metadata: impl Into<BTreeMap<String, String>>) -> Self
pub fn set_metadata(self, metadata: impl Into<BTreeMap<String, String>>) -> Self
This sets the custom metadata to the provided map.
It will clear any previously set metadata.
Keys are case-insensitive: ASCII letters are lowercased. A key must be non-empty and
consist only of a-z, 0-9, and the symbols _ - | ~ % $ # + . :. Keys are checked when
the request is sent, not here, so chaining never fails. send returns
Error::Metadata naming the first invalid key and sends no
request.
Sourcepub fn append_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn append_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Appends the key/value to the custom metadata of this object.
Keys are case-insensitive: ASCII letters are lowercased. A key must be non-empty and
consist only of a-z, 0-9, and the symbols _ - | ~ % $ # + . :. Keys are checked when
the request is sent, not here, so chaining never fails. send returns
Error::Metadata naming the first invalid key and sends no
request.
Source§impl PutBuilder
impl PutBuilder
Sourcepub async fn send(self) -> Result<PutResponse>
pub async fn send(self) -> Result<PutResponse>
Sends the built put request to the upstream service.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PutBuilder
impl !RefUnwindSafe for PutBuilder
impl !Sync for PutBuilder
impl !UnwindSafe for PutBuilder
impl Send for PutBuilder
impl Unpin for PutBuilder
impl UnsafeUnpin for PutBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more