Skip to main content

UploadHook

Trait UploadHook 

Source
pub trait UploadHook: Send + Sync {
    // Required methods
    fn plugin_info(&self) -> &PluginInfo;
    fn get_mode<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = UploadResult<Mode>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn down_and_upload<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        file_name: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = UploadResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn upload_with_key<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
        key: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = UploadResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn upload<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 UploadContext,
    ) -> Pin<Box<dyn Future<Output = UploadResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn get_meta_file_obj<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = UploadResult<Option<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

上传钩子 trait

对应 TypeScript 版本的 BaseUpload

Required Methods§

Source

fn plugin_info(&self) -> &PluginInfo

获取插件信息

Source

fn get_mode<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = UploadResult<Mode>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获得上传模式

Source

fn down_and_upload<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, url: &'life1 str, file_name: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = UploadResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

下载并上传

从 URL 下载文件并上传到存储服务

Source

fn upload_with_key<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, file_path: &'life1 Path, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = UploadResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

指定 Key(路径)上传,本地文件上传到存储服务

路径一致会覆盖源文件

Source

fn upload<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 UploadContext, ) -> Pin<Box<dyn Future<Output = UploadResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

上传文件

Provided Methods§

Source

fn get_meta_file_obj<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = UploadResult<Option<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获得原始操作对象(可选实现)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§