Skip to main content

PutObject

Struct PutObject 

Source
pub struct PutObject<'a> { /* private fields */ }
Expand description

Header字段中:

  • content_md5: 由程序自动添加
  • content_length:由程序自动添加
  • e_tag:不添加

Implementations§

Source§

impl<'a> PutObject<'a>

Source

pub async fn send( &self, object_name: &'a str, object: PutObjectBody<'a>, ) -> Result<PutObjectResponseHeader, Error>

  • content_type,不会进行MIME合法性检查
  • object_name:遵守OSS的Object命名规则
  • data:如果需要创建文件夹,object_name以/结尾,Vec大小为0即可
Source

pub async fn generate_presigned_url( &self, object_name: &str, expires: i32, ) -> Result<String, Error>

生成用于上传的预签名URL(Presigned URL),生成的url使用PUT方法上传文件

在URL中包含签名

OSS不直接提供限制上传文件类型和大小的功能

§参数
  • object_name:要上传的对象名称。必须遵守 OSS Object 命名规则
  • expires:URL 的有效期,单位为秒。过期后将无法使用。

阿里云oss文档不建议使用预签名URL上传带有回调的对象:

该方式常用于预签名URL上传文件的场景,通过将回调参数Base64编码后拼接在URL中实现自动回调。 但由于回调信息暴露在 URL 中,存在一定的安全风险,仅建议用于临时访问或低敏感场景。callback签名

§当使用 STS 临时访问凭证时的注意事项
  • 本方法通过在 URL 中包含签名的方式进行授权,如果使用 STS 访问方式,会自动在查询参数中追加 x-oss-security-token,因此无需再在 Header 中携带该字段。
  • 如需使用 POST 预签名表单上传,请根据 STS 凭证自行构造表单并在表单中携带 x-oss-security-token 字段。
  • 其它正常的 API 请求(非预签名 URL 的方式),需要在 Header 中携带 x-oss-security-token 字段。
Source§

impl<'a> PutObject<'a>

Source

pub fn builder(client: &'a Client) -> PutObjectBuilder<'a>

Create an instance of PutObject using the builder syntax

Trait Implementations§

Source§

impl<'a> Serialize for PutObject<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for PutObject<'a>

§

impl<'a> !RefUnwindSafe for PutObject<'a>

§

impl<'a> Send for PutObject<'a>

§

impl<'a> Sync for PutObject<'a>

§

impl<'a> Unpin for PutObject<'a>

§

impl<'a> UnsafeUnpin for PutObject<'a>

§

impl<'a> !UnwindSafe for PutObject<'a>

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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