upload

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

文件上传工具 - Cli

目录:

1、特点

  • 利用阿里云Oss,上传图片
  • Typora 配合使用,写一些markdown,很方便,不需要本地保存图片
  • 支持多配置路径,适合上传多个文件
  • 个人使用一般是将博客的图片全部上传到阿里云上,个人的一些资料也是,会把url保存住

2、快速开始

1、下载
go get -u -v github.com/anthony-dong/go-tool
2、使用帮助

​ 配置文件来自于 go-tool --config 参数,所以变更配置文件需要指定这个

➜  note git:(master) ✗ bin/go-tool upload -h
NAME:
   upload - 文件上传工具

USAGE:
   upload [command options] [arguments...]

OPTIONS:
   --type value, -t value    Set the upload config type (default: "default")
   --file value, -f value    Set the local path of upload file
   --decode value, -d value  Set the upload file name decode method (uuid|base64|url) (default: "uuid")
   --help, -h                show help (default: false)
3、简单2
➜  note git:(master) ✗ bin/go-tool upload --file ./About.md
2022/01/22 17:41:54.267454 api.go:63: [INFO] [upload] command load config:
{
  "config-file": "/Users/bytedance/note/note/.config/.go-tool.yaml",
  "decode": "uuid",
  "file": "/Users/bytedance/note/note/About.md",
  "log-level": "debug",
  "type": "default"
}
2022/01/22 17:41:54.479533 cli.go:102: [INFO] [upload] end success, url: https://tyut.oss-accelerate.aliyuncs.com/image/2022/1-22/6ec95eb8ce0647ef8578595f3fab004d.md
4、配置文件

支持json 或者 yaml, json需要key命令是下划线模式

Upload:
  Bucket:
    default:
      AccessKeyId: xxxx
      AccessKeySecret: xxx
      Endpoint: oss-accelerate.xxxxx.com
      UrlEndpoint: xxxx.oss-accelerate.xxxx.com
      Bucket: xxxx
      PathPrefix: file # 前缀其实就是 UrlEndpoint/{PathPrefix}/y/m/d/${filename}
    image:
      AccessKeyId: xxxx
      AccessKeySecret: xxxx
      Endpoint: oss-accelerate.xxxxx.com
      UrlEndpoint: xxxx.oss-accelerate.xxxx.com
      Bucket: tyut
      PathPrefix: image

阿里云Oss端配置大概就是这些:

image-20200914135934215

如果参数不输入 -t,则默认走 default标签!,所以一般推荐都设置一个default标签

➜  note git:(master) ✗ bin/go-tool upload --file ./About.md  --type ppt --decode url
2022/01/22 17:58:42.290605 api.go:63: [INFO] [upload] command load config:
{
  "config-file": "/Users/bytedance/note/note/.config/.go-tool.yaml",
  "decode": "url",
  "file": "/Users/bytedance/note/note/About.md",
  "log-level": "debug",
  "type": "ppt"
}
2022/01/22 17:58:42.549348 cli.go:103: [INFO] [upload] end success, url: https://anthony-wangpan.oss-accelerate.aliyuncs.com/ppt/2022/1-22/About.md

4、配合Typora

只需要设置如下: 记得go-tool写成绝对路径,最后验证一下即可

我配置的命令是 /Users/fanhaodong/go/bin/go-tool --log-level fatal upload --file

image-20210116173613955

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUploadCommand

func NewUploadCommand() command.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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