Skip to content

Commit

Permalink
Merge pull request #7 from paradeum-team/yuan
Browse files Browse the repository at this point in the history
add the interface of IPFS version and modify the interface of Confirm upload sharding CarFiles.
  • Loading branch information
freedomiris authored Jun 2, 2023
2 parents 3022df5 + 9fe3578 commit e284c73
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 81 deletions.
Binary file modified chainstorage-sdk
Binary file not shown.
6 changes: 3 additions & 3 deletions chainstorage-sdk.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
server:
#链存服务API地址
chainStorageApiBaseAddress: http://127.0.0.1:8821
chainStorageAPIEndpoint: http://127.0.0.1:8821
#CAR文件工作目录
carFileGenerationPath: ./temp/carfile
carFileWorkPath: ./temp/carfile
#CAR文件分片阈值application.yaml
carFileShardingThreshold: 104857600
#链存服务API token
chainStorageApiToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlLZXkiOiJaT0dKNVI0QTZPU1JIWUlOTUlMQSIsImV4cCI6MTY4NDgzNDUxNSwiaWRlbnRpdHkiOnsiSWQiOjYsIk5pY2tOYW1lIjoidXNlcjEiLCJQcm9maWxlSW1hZ2UiOiIiLCJXYWxsZXRBZGRyIjoidXNlcjEiLCJ0ZXJtaW5hbCI6InBjL3NkayJ9LCJvcmlnX2lhdCI6MTY4MjI0MjUyNH0.w0lQ-RGufy5j3yMfbnL94hOvLeeCSccZbSIwd6kXvbI
chainStorageApiToken:
#HTTP request user agent (K2请求需要)
httpRequestUserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
#HTTP request overtime
Expand Down
13 changes: 7 additions & 6 deletions cmd/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import (
"time"
)

// var (
//
//var (
// offset int
//)
//
// )

func init() {
bucketListCmd.Flags().StringP("Bucket", "b", "", "桶名称")
Expand Down Expand Up @@ -78,7 +79,7 @@ func bucketListRun(cmd *cobra.Command, args []string) {
pageSize = offset
}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -308,7 +309,7 @@ func bucketCreateRun(cmd *cobra.Command, args []string) {
}
}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -461,7 +462,7 @@ func bucketRemoveRun(cmd *cobra.Command, args []string) {

}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -606,7 +607,7 @@ func bucketEmptyRun(cmd *cobra.Command, args []string) {
//
//}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/car.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func carUploadRun(cmd *cobra.Command, args []string) {
processError("ls", err, args)
}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -397,7 +397,7 @@ func carImportRun(cmd *cobra.Command, args []string) {
processError("ls", err, args)
}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down
Binary file removed cmd/chainstorage-cmd
Binary file not shown.
6 changes: 3 additions & 3 deletions cmd/chainstorage-sdk.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
server:
#链存服务API地址
chainStorageApiBaseAddress: http://127.0.0.1:8821
chainStorageAPIEndpoint: http://127.0.0.1:8821
#CAR文件工作目录
carFileGenerationPath: ./temp/carfile
carFileWorkPath: ./temp/carfile
#CAR文件分片阈值application.yaml
carFileShardingThreshold: 104857600
#链存服务API token
chainStorageApiToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlLZXkiOiJaT0dKNVI0QTZPU1JIWUlOTUlMQSIsImV4cCI6MTY4NDgzNDUxNSwiaWRlbnRpdHkiOnsiSWQiOjYsIk5pY2tOYW1lIjoidXNlcjEiLCJQcm9maWxlSW1hZ2UiOiIiLCJXYWxsZXRBZGRyIjoidXNlcjEiLCJ0ZXJtaW5hbCI6InBjL3NkayJ9LCJvcmlnX2lhdCI6MTY4MjI0MjUyNH0.w0lQ-RGufy5j3yMfbnL94hOvLeeCSccZbSIwd6kXvbI
chainStorageApiToken:
#HTTP request user agent (K2请求需要)
httpRequestUserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
#HTTP request user agent (K2请求需要)
Expand Down
Binary file removed cmd/cmd
Binary file not shown.
8 changes: 4 additions & 4 deletions cmd/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func objectListRun(cmd *cobra.Command, args []string) {
pageSize = offset
}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -352,7 +352,7 @@ func objectRenameRun(cmd *cobra.Command, args []string) {

}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -549,7 +549,7 @@ func objectRemoveRun(cmd *cobra.Command, args []string) {
//
//}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down Expand Up @@ -743,7 +743,7 @@ func objectDownloadRun(cmd *cobra.Command, args []string) {
//
//}

sdk, err := chainstoragesdk.New()
sdk, err := chainstoragesdk.New(&applicationConfig)
if err != nil {
//todo: log detail error?
//fmt.Printf("error:%+v\n", err)
Expand Down
4 changes: 4 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package main

import (
"fmt"
chainstoragesdk "github.com/paradeum-team/chainstorage-sdk/sdk"
"github.com/spf13/cobra"
"os"
)

var applicationConfig chainstoragesdk.ApplicationConfig

var cmdDescription string = `
USAGE
gcscmd - Golang ChainStorage Command line tool
Expand Down Expand Up @@ -56,6 +59,7 @@ var rootCmd = &cobra.Command{
}

func Execute() {
applicationConfig = chainstoragesdk.ApplicationConfig{}

rootCmd.AddCommand(
bucketListCmd,
Expand Down
24 changes: 13 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ func main() {
//
//fmt.Printf("response:%+v\n", response)

// region 桶数据
config := chainstoragesdk.ApplicationConfig{}

sdk, err := chainstoragesdk.New()
// region 桶数据
//sdkCfgFile := ""
sdk, err := chainstoragesdk.New(&config)
if err != nil {
fmt.Printf("error:%+v\n", err)
return
Expand Down Expand Up @@ -292,7 +294,7 @@ func main() {
//
// // 请求Url
// urlQuery = strings.TrimSuffix(urlQuery, "&")
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := "api/v1/apiKeys"
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -347,7 +349,7 @@ func main() {
//
// // 请求Url
// urlQuery = strings.TrimSuffix(urlQuery, "&")
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := "api/v1/buckets"
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -396,7 +398,7 @@ func main() {
// }
//
// // 请求Url
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := "api/v1/bucket"
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -437,7 +439,7 @@ func main() {
// }
//
// // 请求Url
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := "api/v1/bucket/status/clean"
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -474,7 +476,7 @@ func main() {
// //todo: bucket id check?
//
// // 请求Url
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := fmt.Sprintf("api/v1/bucket/%d", bucketId)
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -533,7 +535,7 @@ func main() {
//
// // 请求Url
// urlQuery = strings.TrimSuffix(urlQuery, "&")
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := "api/v1/objects/search"
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -577,7 +579,7 @@ func main() {
// }
//
// // 请求Url
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := "api/v1/object"
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -625,7 +627,7 @@ func main() {
// }
//
// // 请求Url
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := fmt.Sprintf("api/v1/object/name/%d", objectId)
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down Expand Up @@ -671,7 +673,7 @@ func main() {
// }
//
// // 请求Url
// apiBaseAddress := conf.myConfig.chainStorageApiBaseAddress
// apiBaseAddress := conf.myConfig.chainStorageAPIEndpoint
// apiPath := fmt.Sprintf("api/v1/object/mark/%d", objectId)
// apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)
//
Expand Down
12 changes: 6 additions & 6 deletions sdk/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (b *Bucket) GetBucketList(bucketName string, pageSize, pageIndex int) (mode
// 请求Url
urlQuery = strings.TrimSuffix(urlQuery, "&")

//apiBaseAddress := conf.cssConfig.ChainStorageApiBaseAddress
apiBaseAddress := b.Config.ChainStorageApiBaseAddress
//apiBaseAddress := conf.cssConfig.ChainStorageApiEndpoint
apiBaseAddress := b.Config.ChainStorageApiEndpoint
apiPath := "api/v1/buckets"
apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)

Expand Down Expand Up @@ -108,7 +108,7 @@ func (b *Bucket) CreateBucket(bucketName string, storageNetworkCode, bucketPrinc
}

// 请求Url
apiBaseAddress := b.Config.ChainStorageApiBaseAddress
apiBaseAddress := b.Config.ChainStorageApiEndpoint
apiPath := "api/v1/bucket"
apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)

Expand Down Expand Up @@ -151,7 +151,7 @@ func (b *Bucket) EmptyBucket(bucketId int) (model.BucketEmptyResponse, error) {
}

// 请求Url
apiBaseAddress := b.Config.ChainStorageApiBaseAddress
apiBaseAddress := b.Config.ChainStorageApiEndpoint
apiPath := "api/v1/bucket/status/clean"
apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)

Expand Down Expand Up @@ -200,7 +200,7 @@ func (b *Bucket) RemoveBucket(bucketId int, autoEmptyBucketData bool) (model.Buc
}

// 请求Url
apiBaseAddress := b.Config.ChainStorageApiBaseAddress
apiBaseAddress := b.Config.ChainStorageApiEndpoint
apiPath := fmt.Sprintf("api/v1/bucket/%d", bucketId)
apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)

Expand Down Expand Up @@ -237,7 +237,7 @@ func (b *Bucket) GetBucketByName(bucketName string) (model.BucketCreateResponse,
return response, err
}

apiBaseAddress := b.Config.ChainStorageApiBaseAddress
apiBaseAddress := b.Config.ChainStorageApiEndpoint
apiPath := fmt.Sprintf("api/v1/bucket/name/%s", url.QueryEscape(bucketName))
apiUrl := fmt.Sprintf("%s%s", apiBaseAddress, apiPath)

Expand Down
Loading

0 comments on commit e284c73

Please sign in to comment.