Giter VIP home page Giter VIP logo

oss-rs's Introduction

aliyun_oss_client 打算采用一种全新的方式来实现

巨大更新,之前使用过的,慎重升级 0.13

目前的实现,代码将大大简化,api接口也更加起清晰,使用了有限的 rust 语言特性,所以接口更加统一, 大大减少了外部依赖

使用本 lib 创建的 oss 命令行工具:tu6ge/oss-cli,也算是本库的一个演示项目

详细使用案例如下:

get Buckets

struct Client {
   key: String,
   secret: String,
}

impl Client {
    async fn get_buckets(&self, endpoint: EndPoint) -> Vec<Bucket> {
        todo!()
    }

    // 导出到自定义的类型
    pub async fn export_buckets<B: DeserializeOwned>(
        &self,
        endpoint: &EndPoint,
    ) -> Result<Vec<B>, OssError> {
        //...
    }
}

get bucket info;

struct Bucket {
    name: String,
    endpoint: EndPoint,
}
impl Bucket{
    async fn get_info(&self, client: &Client) -> BucketInfo {
        todo!()
    }

    // 导出到自定义的类型
    pub async fn export_info<B: DeserializeOwned>(&self, client: &Client) -> Result<B, OssError> {
        //...
    }

    async fn get_object(&self, client: &Client) -> Vec<Object> {
        todo!()
    }

    // 导出到自定义的类型
    pub async fn export_objects<Obj: DeserializeOwned>(
        &self,
        query: &ObjectQuery,
        client: &Client,
    ) -> Result<(Vec<Obj>, NextContinuationToken), OssError> {
        //...
    }
}

get object info

struct Object {
    bucket: Bucket,
    path: ObjectPath,
}
impl Object {
    async fn get_info(&self, client: &Client) -> ObjectInfo {
        todo!()
    }

    async fn upload(&self, client: &Client, content: Vec<u8>) -> Result<(), Error>{
        todo!()
    }
    async fn download(&self, client: &Client) -> Result<Vec<u8>, Error>{
        todo!()
    }
}

oss-rs's People

Contributors

tu6ge avatar w1tcher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

oss-rs's Issues

获取客户端实例那一行直接报错

// 获取客户端实例
let client = aliyun_oss_client::client(key_id,key_secret, endpoint, bucket);

thread 'main' panicked at 'called Res ult::unwrap() on an Err value: Inva
lidEndPoint', /root/.cargo/registry/sr
c/github.com-1ecc6299db9ec823/aliyun-o
ss-client-0.10.1/src/types.rs:197:25
stack backtrace:

使用put_file上传一个.log文件时会提示file type is known错误

使用put_file上传一个.log文件时会提示file type is known错误,

是否能为put_file提供mime_type的设置入口?不然put_file的可用性就比较低了。

看到内部使用了infer模块,但没有定义像.md, .log之类的文本文件的类型,这时就只能使用put_content方法自己定义content_type了。

endpoint 设置了 internal 无效

endpoint as_ref 方法里面缺少对 is_internal 的处理,导致 internal 无效。

    fn as_ref(&self) -> &str {
        use EndPointKind::*;
        let ret = match &self.kind {
            CnHangzhou => HANGZHOU,
            CnShanghai => SHANGHAI,
            CnQingdao => QINGDAO,
            CnBeijing => BEIJING,
            CnZhangjiakou => ZHANGJIAKOU,
            CnHongkong => HONGKONG,
            CnShenzhen => SHENZHEN,
            UsWest1 => US_WEST1,
            UsEast1 => US_EAST1,
            ApSouthEast1 => AP_SOUTH_EAST1,
            Other(str) => str,
        };
        if (self.is_internal) {
            ret + OSS_INTERNAL
        } else {
            ret
        }
    }

如何获取object_list里的返回值?

参考demo里的查询当前 bucket 中的 object 列表,但是返回值 object_list 里的 Object 都是私有属性,无法获取 sizelast_modified 等值

初学者的一点疑惑

作者您好,我是一名初学者,看了一些语法希望直接在项目中继续加深认知,请问当前这个项目可以添加一些详细的启动运行和调试的步骤简介吗?盼您回复~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.