Skip to content

Commit

Permalink
add url
Browse files Browse the repository at this point in the history
  • Loading branch information
nj-jay committed Dec 10, 2020
1 parent 44d0234 commit f7dd641
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
30 changes: 17 additions & 13 deletions cmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ func put(cmd *cobra.Command, params []string){

bucket := viper.GetString("bucket")

//fmt.Println(accessKey)
//
//fmt.Println(secretKey)
//
//fmt.Println(bucket)

putPolicy := storage.PutPolicy{

Scope: bucket,
Expand All @@ -81,13 +75,21 @@ func put(cmd *cobra.Command, params []string){

upToken := putPolicy.UploadToken(mac)

cfg := storage.Config{}
cfg := storage.Config{

ApiHost:"http://api.qiniu.com",

}

bm := storage.NewBucketManager(mac, &cfg)

//bm := storage.NewBucketManager(mac, &cfg)
//
//domains, err := bm.ListBucketDomains(bucket)
//
//fmt.Println(domains)
domains, err := bm.ListBucketDomains(bucket)

if err != nil {

fmt.Println("get domain err")

}

formUploader := storage.NewFormUploader(&cfg)

Expand All @@ -102,7 +104,7 @@ func put(cmd *cobra.Command, params []string){
}


err := formUploader.PutFile(context.Background(), &ret, upToken, upload, path, &putExtra)
err = formUploader.PutFile(context.Background(), &ret, upToken, upload, path, &putExtra)

if err != nil {

Expand All @@ -113,6 +115,8 @@ func put(cmd *cobra.Command, params []string){

fmt.Println("upload successfully")

fmt.Println("外链为:" + "http://" + domains[0].Domain + "/" + upload)

}


Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.14
require (
github.com/mitchellh/go-homedir v1.1.0
github.com/qiniu/api.v7/v7 v7.7.0
github.com/spf13/cast v1.3.0
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
)
Binary file modified qn
Binary file not shown.
Binary file added qn.exe
Binary file not shown.
Binary file added qn_mac
Binary file not shown.
39 changes: 39 additions & 0 deletions test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"github.com/qiniu/api.v7/v7/auth/qbox"
"github.com/qiniu/api.v7/v7/storage"
)

func main() {


accessKey := "0BXxOytiWWOySUiEbg-t8_08c0tvPpwTwDA6Ivfn"

secretKey := "ewA76OHGBEz43vQg-gCqOHd_5paEurmSEzFdx-dz"

bucket := "nj-jay"

mac := qbox.NewMac(accessKey, secretKey)

cfg := storage.Config{

ApiHost: "api.qiniu.com",
}

bm := storage.NewBucketManager(mac, &cfg)

domains, err := bm.ListBucketDomains(bucket)

if err != nil {

fmt.Println(err)

} else {

fmt.Println(domains)
}


}

0 comments on commit f7dd641

Please sign in to comment.