Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d7668c9ff | |||
e65d101476 | |||
0ce7678c21 | |||
c08b4bf90d | |||
74e88e62d5 | |||
55275db618 | |||
a72c860511 |
@ -260,7 +260,7 @@ func (f *Fetcher) fetchChunk(index int) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
var buf = make([]byte, 8192)
|
||||
var buf = make([]byte, 64*1024) // 64KB
|
||||
|
||||
// 重试10次
|
||||
for i := 0; i < 10; i++ {
|
||||
|
@ -57,12 +57,10 @@ type PutRet struct {
|
||||
}
|
||||
|
||||
func New(accessKey, secretKey, bucket, domain, securityKey string) QiNiu {
|
||||
region, _ := storage.GetRegion(accessKey, bucket)
|
||||
mac := qbox.NewMac(accessKey, secretKey)
|
||||
conf := &storage.Config{
|
||||
Region: region, //空间所在的存储区域
|
||||
UseHTTPS: true, //是否使用https域名
|
||||
UseCdnDomains: true, //上传是否使用CDN上传加速
|
||||
UseHTTPS: true, //是否使用https域名
|
||||
UseCdnDomains: false, //上传是否使用CDN上传加速
|
||||
}
|
||||
return &qiNiu{
|
||||
mac: mac,
|
||||
@ -216,7 +214,7 @@ func (q *qiNiu) GetFileHash(path, qhash string) (hash string, err error) {
|
||||
}
|
||||
|
||||
sign := q.TimestampSecuritySign(path, time.Second*5)
|
||||
addr := fmt.Sprintf("https://cdn.mogume.com/%s?%s&qhash/%s", path, sign, qhash)
|
||||
addr := fmt.Sprintf("%s/%s?%s&qhash/%s", strings.TrimRight(q.domain, "/"), path, sign, qhash)
|
||||
|
||||
resp, err := http.Get(addr)
|
||||
if err != nil {
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"math"
|
||||
"math/rand"
|
||||
@ -43,7 +44,7 @@ func ByteFmt(size int64) string {
|
||||
if frac > 0 {
|
||||
return fmt.Sprintf("%.1f%s", math.Floor(val*10)/10, unitArr[p])
|
||||
} else {
|
||||
return fmt.Sprintf("%d%s", int(val), unitArr[p])
|
||||
return fmt.Sprintf("%d%s", cast.ToInt(val), unitArr[p])
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user