Git Product home page Git Product logo

cos-go-sdk-v5's Introduction

cos-go-sdk-v5

腾讯云 对象储存(cos) API5.0 golang sdk


安装使用


安装

go get -u github.com/nelsonken/cos-go-sdk-v5/cos

使用

package main

import "github.com/nelsonken/cos-go-sdk-v5/cos"

client := cos.New(&cos.Option{})
client.Bucket(name).PutObject(...)

功能概述

bucket所有功能完备(生命周期,跨域除外);object的操作(完备):增、删、查、改、下载、复制;


bucket


  • 列出bucket列表
  • 创建bucket
  • 删除bucket
  • 设置bucket ACL
  • 列出bucket内容
  • bucket是否存在
  • 列出正在上传的obj
  • ACL设置
  • CORS 跨域
  • lifcycle设置

object


  • 普通上传
  • 多线程分片上传(整合分片上传)
  • 删除
  • 下载
  • 复制
  • 初始化分片上传
  • 上传分片
  • 列出正在上传分片
  • 完成分片上传
  • 放弃上传

cos-go-sdk-v5's People

Contributors

eraac avatar nelsonken 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

Watchers

 avatar  avatar  avatar

cos-go-sdk-v5's Issues

不能引用

github.com/nelsonken/cos-go-sdk-v5/cos: github.com/nelsonken/[email protected]: parsing go.mod:
module declares its path as: github.com/fpay/cos-go-sdk-v5
but was required as: github.com/nelsonken/cos-go-sdk-v5

两处BUG

发现5个月之前的版本两处BUG,不知道最近的更新是否有修复,未发现代码的更新,只看到readme提示

1、协程Worker中:
err = b.UploadSlice(ctx, job.UploadID, job.Dst, job.Number, job.MD5, content)
没有对分片上传错误做处理,如果错误会造成程序退出

2、分片上传
res, err := b.conn.Do(ctx, "PUT", b.Name, dst, param, nil, content)
错误未处理,造成程序退出。

建议:在文件上传新增自定义headers

UploadObject上传一个文件,为什么content-length一直为0

`
func UploadObject() {
bu := "kapucostest"
ctx := cos.GetTimeoutCtx(time.Second * 30)
objName := "img.jpg"
f,err := os.Open("img.jpg")
if err != nil {
fmt.Println(err.Error())
return
}
defer f.Close()

err = client.Bucket(bu).UploadObject(ctx, objName, f, &cos.AccessControl{})

if err != nil {
    fmt.Println(err.Error())
} 

}
`

输出:
Put Object:
411:请求被拒绝You must provide the Content-Length HTTP header.

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.