Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions storage/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import (
"strconv"
"strings"

"net/http"

"github.com/qiniu/api.v7/auth/qbox"
"github.com/qiniu/api.v7/conf"
"net/http"
)

// 资源管理相关的默认域名
const (
DefaultRsHost = "rs.qiniu.com"
DefaultRsfHost = "rsf.qiniu.com"
DefaultAPIHost = "api.qiniu.com"
DefaultPubHost = "pu.qbox.me:10200"
DefaultPubHost = "pu.qbox.me"
)

// FileInfo 文件基本信息
Expand Down Expand Up @@ -472,7 +473,7 @@ func (m *BucketManager) AsyncFetch(param AsyncFetchParam) (ret AsyncFetchRet, er

reqUrl += "/sisyphus/fetch"

ctx := context.WithValue(context.TODO(), "mac", m.mac)
ctx := context.WithValue(context.TODO(), "mac:Qiniu", m.mac)
headers := http.Header{}
headers.Add("Content-Type", conf.CONTENT_TYPE_JSON)
err = m.client.CallWithJson(ctx, &ret, "POST", reqUrl, headers, param)
Expand Down
2 changes: 1 addition & 1 deletion storage/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func TestChangeType(t *testing.T) {
func TestPrefetchAndImage(t *testing.T) {
err := bucketManager.SetImage(testSiteUrl, testBucket)
if err != nil {
t.Fatalf("SetImage() error, %s", err)
t.Fatalf("SetImage() error, %+v", err)
}

t.Log("set image success for bucket", testBucket)
Expand Down
11 changes: 10 additions & 1 deletion storage/form_upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ import (
)

var (
testLocalFile = filepath.Join(os.Getenv("TRAVIS_BUILD_DIR"), "Makefile")
testLocalFile string
)

func init() {
pwd, err := os.Getwd()
if err != nil {
fmt.Println(err)
}
exPath := filepath.Dir(pwd)
testLocalFile = filepath.Join(exPath, "Makefile")
}

func TestFormUploadPutFile(t *testing.T) {
var putRet PutRet
ctx := context.TODO()
Expand Down
23 changes: 19 additions & 4 deletions storage/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/qiniu/api.v7/auth/qbox"
"github.com/qiniu/api.v7/conf"
"github.com/qiniu/x/reqid.v7"
. "golang.org/x/net/context"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"runtime"
"strings"

"github.com/qiniu/api.v7/auth/qbox"
"github.com/qiniu/api.v7/conf"
"github.com/qiniu/x/reqid.v7"
. "golang.org/x/net/context"
)

var UserAgent = "Golang qiniu/rpc package"
Expand Down Expand Up @@ -53,13 +54,27 @@ func newRequest(ctx Context, method, reqUrl string, headers http.Header, body io

//check access token
mac, ok := ctx.Value("mac").(*qbox.Mac)
if !ok {
mac, ok = ctx.Value("mac:QBox").(*qbox.Mac)
}
if ok {
token, signErr := mac.SignRequest(req)
if signErr != nil {
err = signErr
return
}
req.Header.Add("Authorization", "QBox "+token)
return
}
mac, ok = ctx.Value("mac:Qiniu").(*qbox.Mac)
if ok {
token, signErr := mac.SignRequestV2(req)
if signErr != nil {
err = signErr
return
}
req.Header.Add("Authorization", "Qiniu "+token)
return
}

return
Expand Down
1 change: 0 additions & 1 deletion test-env.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ export QINIU_TEST_BUCKET_PRIVATE=gosdk.qiniudn.com
export QINIU_TEST_DOMAIN=gosdk.qiniudn.com
export QINIU_TEST_DOMAIN_PRIVATE=gosdk.qiniudn.com
export QINIU_TEST_PIPELINE=sdktest
export TRAVIS_BUILD_DIR=/Users/jemy/Downloads