UrlApi

Trait UrlApi 

Source
pub trait UrlApi: OSSInfo + API {
    // Required methods
    fn sign_download_url<S: AsRef<str>>(
        &self,
        key: S,
        build: &RequestBuilder,
    ) -> String;
    fn sign_upload_url<S: AsRef<str>>(
        &self,
        key: S,
        build: &RequestBuilder,
    ) -> String;
    fn sign_url<S: AsRef<str>>(&self, key: S, build: &RequestBuilder) -> String;
}

Required Methods§

Source

fn sign_download_url<S: AsRef<str>>( &self, key: S, build: &RequestBuilder, ) -> String

获取签名下载URL

§使用例子
use aliyun_oss_rust_sdk::oss::{OSS, RequestBuilder};
use aliyun_oss_rust_sdk::url::UrlApi;
let oss = OSS::from_env();//也可以使用OSS::new()方法传递参数
let build = RequestBuilder::new()
   //.with_cdn("https://mydomain.com")
   .with_expire(60) //60秒链接过期
  .oss_download_speed_limit(30);//限速30kb
let download_url = oss.sign_download_url(
    "/ipas/cn/-10/ipadump.com_imem内存修改器_1.0.0.ipa",
    &build
    );
 println!("download_url: {}", download_url);
Source

fn sign_upload_url<S: AsRef<str>>( &self, key: S, build: &RequestBuilder, ) -> String

获取签名上传URL

§使用例子
use aliyun_oss_rust_sdk::oss::{OSS, RequestBuilder};
use aliyun_oss_rust_sdk::url::UrlApi;
let oss = OSS::from_env();//也可以使用OSS::new()方法传递参数
let build = RequestBuilder::new()
   //.with_cdn("https://mydomain.com")
   .with_content_type("text/plain") //设置上传文件的content-type
   .with_expire(60); //60秒链接过期
let upload_url = oss.sign_upload_url(
    "tmp.txt",
    &build
    );
 println!("upload_url: {}", upload_url);
//使用postman测试上传即可,PS:要注意content-type要和build中的一致
Source

fn sign_url<S: AsRef<str>>(&self, key: S, build: &RequestBuilder) -> String

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§