-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Releases/v2.16.0 #417
Merged
Merged
Releases/v2.16.0 #417
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
27c1ba2
upgrade go sdk
bachue ba6dc34
support `create-share`, `share-ls`, `share-cp` commands
bachue 9fab1c7
now listbucket2 provides precise marker even with the `--limit` option
bachue 02f2c99
support uploading acceleration
bachue 9b28851
now pfop supports `--workflow-template-id` and `--type`
bachue 95203cf
upgrade go sdk
bachue 1666cc4
compatible with go v1.20
bachue 8e5de54
fix the download to path bug
bachue 5a3aa97
adjust share-cp logics
bachue 1d0135a
fix the panic if pfop failed
bachue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package cmd | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/qiniu/qshell/v2/docs" | ||
"github.com/qiniu/qshell/v2/iqshell" | ||
"github.com/qiniu/qshell/v2/iqshell/storage/object/operations" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var createShareCmdBuilder = func(cfg *iqshell.Config) *cobra.Command { | ||
var info = operations.CreateShareInfo{} | ||
var cmd = &cobra.Command{ | ||
Use: "create-share [kodo://]<Bucket>/<Prefix>", | ||
Short: "Share the specified directory", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg.CmdCfg.CmdId = docs.CreateShareType | ||
if len(args) > 0 { | ||
url := args[0] | ||
url = strings.TrimPrefix(url, "kodo://") | ||
parts := strings.SplitN(url, "/", 2) | ||
if len(parts) > 0 { | ||
info.Bucket = parts[0] | ||
} | ||
if len(parts) > 1 { | ||
info.Prefix = parts[1] | ||
} | ||
info.Permission = "READONLY" | ||
} | ||
operations.CreateShare(cfg, info) | ||
}, | ||
} | ||
cmd.Flags().StringVarP(&info.ExtractCode, "extract-code", "", "", "Specify extract code for the share, must consist of 6 alphabets and numbers") | ||
cmd.Flags().Int64VarP(&info.DurationSeconds, "validity-period", "", 900, "Specify validity period in seconds, must be longer than 1 mintutes and shorter than 2 hours") | ||
cmd.Flags().StringVarP(&info.OutputPath, "output", "", "", "Specify path to save output") | ||
return cmd | ||
} | ||
|
||
var listShareCmdBuilder = func(cfg *iqshell.Config) *cobra.Command { | ||
var info = operations.ListShareInfo{} | ||
var cmd = &cobra.Command{ | ||
Use: "share-ls <Link>", | ||
Short: "List shared files", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg.CmdCfg.CmdId = docs.ShareLsType | ||
if len(args) > 0 { | ||
info.LinkURL = args[0] | ||
} | ||
operations.ListShare(cfg, info) | ||
}, | ||
} | ||
cmd.Flags().StringVarP(&info.ExtractCode, "extract-code", "", "", "Specify extract code for the share, must consist of 6 alphabets and numbers") | ||
cmd.Flags().StringVarP(&info.Prefix, "prefix", "p", "", "list the shared directory with this prefix if set") | ||
cmd.Flags().Int64VarP(&info.Limit, "limit", "n", 0, "max count of items to output") | ||
cmd.Flags().StringVarP(&info.Marker, "marker", "m", "", "list marker") | ||
return cmd | ||
} | ||
|
||
var copyShareCmdBuilder = func(cfg *iqshell.Config) *cobra.Command { | ||
var info = operations.CopyShareInfo{} | ||
var cmd = &cobra.Command{ | ||
Use: "share-cp <Link> --to=<ToPath>", | ||
Short: "Copy shared files", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg.CmdCfg.CmdId = docs.ShareCpType | ||
if len(args) > 0 { | ||
info.LinkURL = args[0] | ||
} | ||
operations.CopyShare(cfg, info) | ||
}, | ||
} | ||
cmd.Flags().StringVarP(&info.ExtractCode, "extract-code", "", "", "Specify extract code for the share, must consist of 6 alphabets and numbers") | ||
cmd.Flags().StringVarP(&info.FromPath, "from", "", "", "copy from path") | ||
cmd.Flags().StringVarP(&info.ToPath, "to", "", "", "copy to path") | ||
cmd.Flags().BoolVarP(&info.Recursive, "recursive", "r", false, "copy directories recursively") | ||
return cmd | ||
} | ||
|
||
func init() { | ||
registerLoader(shareCmdLoader) | ||
} | ||
|
||
func shareCmdLoader(superCmd *cobra.Command, cfg *iqshell.Config) { | ||
superCmd.AddCommand( | ||
createShareCmdBuilder(cfg), | ||
listShareCmdBuilder(cfg), | ||
copyShareCmdBuilder(cfg), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package docs | ||
|
||
import _ "embed" | ||
|
||
//go:embed create-share.md | ||
var createShareDocument string | ||
|
||
const CreateShareType = "create-share" | ||
|
||
func init() { | ||
addCmdDocumentInfo(CreateShareType, createShareDocument) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 简介 | ||
`create-share` 命令为需要分享的目录创建授权链接。 | ||
|
||
# 格式 | ||
``` | ||
qshell create-share [kodo://]<Bucket>/<Prefix> | ||
``` | ||
|
||
# 帮助文档 | ||
可以在命令行输入如下命令获取帮助文档: | ||
``` | ||
// 简单描述 | ||
$ qshell create-share -h | ||
|
||
// 详细文档(此文档) | ||
$ qshell create-share --doc | ||
``` | ||
|
||
# 鉴权 | ||
需要使用 `qshell account` 或者 `qshell user add` 命令设置鉴权信息 `AccessKey`, `SecretKey` 和 `Name`。 | ||
|
||
# 参数 | ||
- Bucket: 空间名称【必选】 | ||
- Prefix: 前缀【必选】 | ||
|
||
# 选项 | ||
- --extract-code: 提取码,只能包含六位大小写字母或者数字,如果不填写,将会自动生成。【可选】 | ||
- --validity-period: 有效时间,如果不填写,默认为 15 分钟。【可选】 | ||
- --output: 保存路径,以 JSON 格式保存输出内容,如果不填写,则直接以文本形式输出。【可选】 | ||
|
||
# 示例 | ||
``` | ||
$ qshell create-share kodo://bucketname/prefix | ||
Link: | ||
http://portal.qiniu.com/kodo-shares/verify?id=AGQEKDRxBBjbGmsKduQS9oFx59rz&token=qhtbC5YmDCO-WiPriuoCG_t4hZ1LboSOtRYSJXo_%3A9uJY8FiNrKjNrt4MpBx547jlgwr8aes15z5i8VY6l5SU6ga2IKWDBSGTv1jo-rOocklE7QqApzG6okJktZ36umLoqv9x1kuo5fNmgasLXowyTuHIM3kXsaV_DoXmvQsGr5ol6j4RtrmLcKdtXhpkGH8MfSjEgRV91Bx_Q_mSwpJ1028p8yZCSad_QOu_kSPxzeLZmWlUpAtO2oEXdbMTBxhTCH_3awCgqkgoogi0FQGP4zHxeFr0n3vj69DpmWqe6DiYbYLivCuU0kOF5Khv4I6-w6vjjdY | ||
Extract Code: | ||
wp7gqc | ||
Expire: | ||
2024-10-09 10:44:41 +0000 | ||
|
||
$ qshell create-share --output=share.json kodo://bucketname/prefix | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
share-create share-cp share-ls 这样是不是风格更统一些?