2017-03-04 05:06:32 -05:00
|
|
|
|
package oss
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2019-10-28 17:31:07 -04:00
|
|
|
|
// HTTPTimeout http timeout
|
2017-03-04 05:06:32 -05:00
|
|
|
|
type HTTPTimeout struct {
|
|
|
|
|
ConnectTimeout time.Duration
|
|
|
|
|
ReadWriteTimeout time.Duration
|
|
|
|
|
HeaderTimeout time.Duration
|
|
|
|
|
LongTimeout time.Duration
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 17:31:07 -04:00
|
|
|
|
// Config oss configure
|
2017-03-04 05:06:32 -05:00
|
|
|
|
type Config struct {
|
2019-10-28 17:31:07 -04:00
|
|
|
|
Endpoint string // oss地址
|
|
|
|
|
AccessKeyID string // accessId
|
|
|
|
|
AccessKeySecret string // accessKey
|
|
|
|
|
RetryTimes uint // 失败重试次数,默认5
|
|
|
|
|
UserAgent string // SDK名称/版本/系统信息
|
|
|
|
|
IsDebug bool // 是否开启调试模式,默认false
|
|
|
|
|
Timeout uint // 超时时间,默认60s
|
|
|
|
|
SecurityToken string // STS Token
|
|
|
|
|
IsCname bool // Endpoint是否是CNAME
|
|
|
|
|
HTTPTimeout HTTPTimeout // HTTP的超时时间设置
|
|
|
|
|
IsUseProxy bool // 是否使用代理
|
|
|
|
|
ProxyHost string // 代理服务器地址
|
|
|
|
|
IsAuthProxy bool // 代理服务器是否使用用户认证
|
|
|
|
|
ProxyUser string // 代理服务器认证用户名
|
|
|
|
|
ProxyPassword string // 代理服务器认证密码
|
|
|
|
|
IsEnableMD5 bool // 上传数据时是否启用MD5校验
|
|
|
|
|
MD5Threshold int64 // 内存中计算MD5的上线大小,大于该值启用临时文件,单位Byte
|
|
|
|
|
IsEnableCRC bool // 上传数据时是否启用CRC64校验
|
2017-03-04 05:06:32 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 17:31:07 -04:00
|
|
|
|
// 获取默认配置
|
2017-03-04 05:06:32 -05:00
|
|
|
|
func getDefaultOssConfig() *Config {
|
|
|
|
|
config := Config{}
|
|
|
|
|
|
|
|
|
|
config.Endpoint = ""
|
|
|
|
|
config.AccessKeyID = ""
|
|
|
|
|
config.AccessKeySecret = ""
|
|
|
|
|
config.RetryTimes = 5
|
|
|
|
|
config.IsDebug = false
|
2019-10-28 17:31:07 -04:00
|
|
|
|
config.UserAgent = userAgent
|
|
|
|
|
config.Timeout = 60 // seconds
|
2017-03-04 05:06:32 -05:00
|
|
|
|
config.SecurityToken = ""
|
|
|
|
|
config.IsCname = false
|
|
|
|
|
|
|
|
|
|
config.HTTPTimeout.ConnectTimeout = time.Second * 30 // 30s
|
|
|
|
|
config.HTTPTimeout.ReadWriteTimeout = time.Second * 60 // 60s
|
|
|
|
|
config.HTTPTimeout.HeaderTimeout = time.Second * 60 // 60s
|
|
|
|
|
config.HTTPTimeout.LongTimeout = time.Second * 300 // 300s
|
|
|
|
|
|
|
|
|
|
config.IsUseProxy = false
|
|
|
|
|
config.ProxyHost = ""
|
|
|
|
|
config.IsAuthProxy = false
|
|
|
|
|
config.ProxyUser = ""
|
|
|
|
|
config.ProxyPassword = ""
|
|
|
|
|
|
|
|
|
|
config.MD5Threshold = 16 * 1024 * 1024 // 16MB
|
|
|
|
|
config.IsEnableMD5 = false
|
|
|
|
|
config.IsEnableCRC = true
|
|
|
|
|
|
|
|
|
|
return &config
|
|
|
|
|
}
|