pub struct UploadManager(_);
Expand description

上传管理器

Implementations§

创建上传管理构建器

Examples found in repository?
src/upload_manager.rs (line 34)
33
34
35
    pub fn new(upload_token: impl Into<UploadTokenSigner>) -> Self {
        Self::builder(upload_token).build()
    }

创建上传管理器

获取上传凭证签发器

Examples found in repository?
src/multi_parts_uploader/mod.rs (line 303)
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
    fn access_key(&self) -> ApiResult<AccessKey> {
        self.upload_manager().upload_token().access_key()
    }

    fn bucket_name(&self) -> ApiResult<BucketName> {
        self.upload_manager().upload_token().bucket_name()
    }

    #[cfg(feature = "async")]
    fn async_access_key(&self) -> BoxFuture<ApiResult<AccessKey>> {
        Box::pin(async move { self.upload_manager().upload_token().async_access_key().await })
    }

    #[cfg(feature = "async")]
    fn async_bucket_name(&self) -> BoxFuture<ApiResult<BucketName>> {
        Box::pin(async move { self.upload_manager().upload_token().async_bucket_name().await })
    }

    fn get_bucket_regions(&self, params: &ObjectParams) -> ApiResult<GotRegions> {
        if let Some(region_provider) = params.region_provider() {
            region_provider.get_all(Default::default())
        } else {
            self.get_bucket_region()?.get_all(Default::default())
        }
    }

    #[cfg(feature = "async")]
    fn async_get_bucket_regions<'a>(&'a self, params: &'a ObjectParams) -> BoxFuture<'a, ApiResult<GotRegions>> {
        Box::pin(async move {
            if let Some(region_provider) = params.region_provider() {
                region_provider.async_get_all(Default::default()).await
            } else {
                self.async_get_bucket_region()
                    .await?
                    .async_get_all(Default::default())
                    .await
            }
        })
    }

    fn get_up_endpoints(&self, params: &ObjectParams) -> ApiResult<Endpoints> {
        let options = EndpointsGetOptions::builder().service_names(&[ServiceName::Up]).build();
        let up_endpoints = if let Some(region_provider) = params.region_provider() {
            RegionsProviderEndpoints::new(region_provider)
                .get_endpoints(options)?
                .into_owned()
        } else {
            RegionsProviderEndpoints::new(self.get_bucket_region()?)
                .get_endpoints(options)?
                .into_owned()
        };
        Ok(up_endpoints)
    }

    #[cfg(feature = "async")]
    fn async_get_up_endpoints<'a>(&'a self, params: &'a ObjectParams) -> BoxFuture<'a, ApiResult<Endpoints>> {
        Box::pin(async move {
            let options = EndpointsGetOptions::builder().service_names(&[ServiceName::Up]).build();
            let up_endpoints = if let Some(region_provider) = params.region_provider() {
                RegionsProviderEndpoints::new(region_provider)
                    .async_get_endpoints(options)
                    .await?
                    .into_owned()
            } else {
                RegionsProviderEndpoints::new(self.async_get_bucket_region().await?)
                    .async_get_endpoints(options)
                    .await?
                    .into_owned()
            };
            Ok(up_endpoints)
        })
    }

    fn get_bucket_region(&self) -> ApiResult<BucketRegionsProvider> {
        Ok(self
            .upload_manager()
            .queryer()
            .query(self.access_key()?, self.bucket_name()?))
    }

    #[cfg(feature = "async")]
    fn async_get_bucket_region(&self) -> BoxFuture<ApiResult<BucketRegionsProvider>> {
        Box::pin(async move {
            Ok(self
                .upload_manager()
                .queryer()
                .query(self.async_access_key().await?, self.async_bucket_name().await?))
        })
    }

    fn make_upload_token_signer(&self, object_name: Option<ObjectName>) -> OwnedUploadTokenProviderOrReferenced<'_> {
        self.upload_manager()
            .upload_token()
            .make_upload_token_provider(object_name)
    }
More examples
Hide additional examples
src/single_part_uploader/form_uploader.rs (line 387)
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
    fn make_upload_token_signer(&self, params: &ObjectParams) -> OwnedUploadTokenProviderOrReferenced<'_> {
        let object_name = params.object_name().map(ObjectName::from);
        self.upload_manager
            .upload_token()
            .make_upload_token_provider(object_name)
    }

    fn put_object(&self) -> put_object::Client {
        self.upload_manager.client().storage().put_object()
    }

    fn access_key(&self) -> ApiResult<AccessKey> {
        self.upload_manager.upload_token().access_key()
    }

    fn bucket_name(&self) -> ApiResult<BucketName> {
        self.upload_manager.upload_token().bucket_name()
    }

    #[cfg(feature = "async")]
    async fn async_access_key(&self) -> ApiResult<AccessKey> {
        self.upload_manager.upload_token().async_access_key().await
    }

    #[cfg(feature = "async")]
    async fn async_bucket_name(&self) -> ApiResult<BucketName> {
        self.upload_manager.upload_token().async_bucket_name().await
    }

获取七牛 API 调用客户端

Examples found in repository?
src/multi_parts_uploader/mod.rs (line 299)
298
299
300
    fn storage(&self) -> storage::Client {
        self.upload_manager().client().storage()
    }
More examples
Hide additional examples
src/single_part_uploader/form_uploader.rs (line 392)
391
392
393
    fn put_object(&self) -> put_object::Client {
        self.upload_manager.client().storage().put_object()
    }

获取存储空间相关区域查询器

Examples found in repository?
src/single_part_uploader/form_uploader.rs (line 372)
369
370
371
372
373
374
375
376
377
378
379
380
381
382
    fn get_bucket_region(&self) -> ApiResult<BucketRegionsProvider> {
        Ok(self
            .upload_manager
            .queryer()
            .query(self.access_key()?, self.bucket_name()?))
    }

    #[cfg(feature = "async")]
    async fn async_get_bucket_region(&self) -> ApiResult<BucketRegionsProvider> {
        Ok(self
            .upload_manager
            .queryer()
            .query(self.async_access_key().await?, self.async_bucket_name().await?))
    }
More examples
Hide additional examples
src/multi_parts_uploader/mod.rs (line 378)
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
    fn get_bucket_region(&self) -> ApiResult<BucketRegionsProvider> {
        Ok(self
            .upload_manager()
            .queryer()
            .query(self.access_key()?, self.bucket_name()?))
    }

    #[cfg(feature = "async")]
    fn async_get_bucket_region(&self) -> BoxFuture<ApiResult<BucketRegionsProvider>> {
        Box::pin(async move {
            Ok(self
                .upload_manager()
                .queryer()
                .query(self.async_access_key().await?, self.async_bucket_name().await?))
        })
    }

创建默认的单请求上传器

创建表单上传器

Examples found in repository?
src/upload_manager.rs (line 58)
57
58
59
    pub fn single_part_uploader(&self) -> impl SinglePartUploader {
        self.form_uploader()
    }

创建默认的分片上传器

创建分片上传器 V1

创建分片上传器 V2

Examples found in repository?
src/upload_manager.rs (line 73)
69
70
71
72
73
74
    pub fn multi_parts_uploader<H: Digest + Send + 'static, R: ResumableRecorder<HashAlgorithm = H> + 'static>(
        &self,
        resumable_recorder: R,
    ) -> impl MultiPartsUploader<HashAlgorithm = H> {
        self.multi_parts_v2_uploader(resumable_recorder)
    }

创建自动上传器

创建自动上传构建器

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function.
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds.
Calls .tap_borrow() only in debug builds, and is erased in release builds.
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Calls .tap_ref() only in debug builds, and is erased in release builds.
Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Calls .tap_deref() only in debug builds, and is erased in release builds.
Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more