common

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdCreate = &cobra.Command{
	Use:   "create",
	Short: "新建存储空间(bucket) 或者 文件对象(object)",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		if bucket != "" && object == "" {
			err := bClient.CreateBucket(bucket)
			if err != nil {
				fmt.Printf("新建存储空间(bucket) %v 出错,具体错误如下:", bucket)
				fmt.Println("")
				fmt.Println(err)
			} else {
				fmt.Printf("新建存储空间(bucket):%v ", bucket)
			}
		} else {
			fmt.Println("指定命令参数不完整,需指定存储空间,文件对象,以及本地路径,具体可使用帮助命令 -h or --help")
		}
	},
}

CmdCreate 创建存储空间

View Source
var CmdDelete = &cobra.Command{
	Use:   "delete",
	Short: "删除指定存储空间(bucket) 或者 文件对象(object)",

	Run: func(cmd *cobra.Command, args []string) {
		if bucket != "" && object == "" {
			err := bClient.DeleteBucket(bucket)
			if err != nil {
				fmt.Printf("删除指定存储空间(bucket) %v 出错,具体错误如下:", bucket)
				fmt.Println("")
				fmt.Println(err)
			} else {
				fmt.Printf("已删除指定存储空间(bucket):%v", bucket)
			}
		} else if bucket != "" && object != "" {
			err := oClient.DeleteObject(bucket, object)
			if err != nil {
				fmt.Printf("删除指定文件对象(object) %v 出错,具体错误如下:", object)
				fmt.Println("")
				fmt.Println(err)
			} else {
				fmt.Printf("已删除指定文件对象(object):%v", object)
			}
		} else {
			fmt.Println("指定命令参数不完整,需指定存储空间,文件对象,以及本地路径,具体可使用帮助命令 -h or --help")
		}
	},
}
View Source
var CmdDownload = &cobra.Command{
	Use:   "download",
	Short: "下载指定的文件对象(object)",

	Run: func(cmd *cobra.Command, args []string) {
		if bucket != "" && object != "" && filepath != "" {
			err := oClient.GetObject(bucket, object, filepath)
			if err != nil {
				fmt.Printf("下载指定的文件对象(object) %v"+" 出错,具体错误如下:", object)
				fmt.Println("")
				fmt.Println(err)
			} else {
				fmt.Printf("已下载指定的文件对象(object):%v 至 本地路径:%v", object, filepath)
			}
		} else {
			fmt.Println("指定命令参数不完整,需指定存储空间,文件对象,以及本地路径,具体可使用帮助命令 -h or --help")
		}
	},
}
View Source
var CmdGet = &cobra.Command{
	Use:   "get",
	Short: "获取存储空间(bucket) 或者 文件对象(object) 列表",
}
View Source
var CmdUp = &cobra.Command{
	Use:   "up",
	Short: "上传指定文件 或者 并发上传指定目录以及子目录下符合过滤条件的文件",

	Run: func(cmd *cobra.Command, args []string) {
		if bucket != "" && filepath != "" {
			err := upload.Upload(filepath, suffix, bucket, object, oClient)
			if err != nil {
				fmt.Println("上传指定文件或目录出错,具体错误如下:")
				fmt.Println(err)
			} else {
				fmt.Printf("上传指定文件或目录成功")
			}
		} else {
			fmt.Println("指定命令参数不完整,需指定存储空间,文件对象,以及本地路径,具体可使用帮助命令 -h or --help")
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL