release v1.20

This commit is contained in:
deepzz0
2017-06-14 21:25:18 +08:00
parent 1634418a13
commit 54f5289d6b
134 changed files with 26141 additions and 18531 deletions
+30
View File
@@ -2,6 +2,7 @@ package kodo
import (
"encoding/base64"
"fmt"
"io"
"net/url"
"strconv"
@@ -60,6 +61,7 @@ type Entry struct {
Fsize int64 `json:"fsize"`
PutTime int64 `json:"putTime"`
MimeType string `json:"mimeType"`
Type int `json:"type"`
EndUser string `json:"endUser"`
}
@@ -123,6 +125,16 @@ func (p Bucket) ChangeMime(ctx Context, key, mime string) (err error) {
return p.Conn.Call(ctx, nil, "POST", p.Conn.RSHost+URIChangeMime(p.Name, key, mime))
}
// 修改文件的存储类型。
//
// ctx 是请求的上下文。
// key 是要修改的文件的访问路径。
// fileType 是要设置的新存储类型。
//
func (p Bucket) ChangeType(ctx Context, key string, fileType int) (err error) {
return p.Conn.Call(ctx, nil, "POST", p.Conn.RSHost+URIChangeType(p.Name, key, fileType))
}
// 从网上抓取一个资源并存储到七牛空间(bucket)中。
//
// ctx 是请求的上下文。
@@ -133,6 +145,16 @@ func (p Bucket) Fetch(ctx Context, key string, url string) (err error) {
return p.Conn.Call(ctx, nil, "POST", p.IoHost+uriFetch(p.Name, key, url))
}
// 更新文件生命周期
//
// ctx 是请求的上下文。
// key 是要更新的文件的访问路径。
// deleteAfterDays 设置为0表示取消 lifecycle
//
func (p Bucket) DeleteAfterDays(ctx Context, key string, days int) (err error) {
return p.Conn.Call(ctx, nil, "POST", p.Conn.RSHost+URIDeleteAfterDays(p.Name, key, days))
}
// ----------------------------------------------------------
type ListItem struct {
@@ -275,4 +297,12 @@ func URIChangeMime(bucket, key, mime string) string {
return "/chgm/" + encodeURI(bucket+":"+key) + "/mime/" + encodeURI(mime)
}
func URIChangeType(bucket, key string, fileType int) string {
return "/chtype/" + encodeURI(bucket+":"+key) + "/type/" + strconv.Itoa(fileType)
}
func URIDeleteAfterDays(bucket, key string, days int) string {
return fmt.Sprintf("/deleteAfterDays/%s/%d", encodeURI(bucket+":"+key), days)
}
// ----------------------------------------------------------