使用 Minio Client 访问滴滴云 S3 对象存储

如何申请滴滴云 S3 的 Bucket?

先注册 滴滴云账号,进入:https://app.didiyun.com/#/s3/add 申请 Bucket,如下图:

填写名称和设置访问权限,点立即创建即可。

如何申请 AK 和 SK?

操作步骤:

  1. 点击“API”按钮。
  2. 选择“对象存储密钥”。
  3. 点击“创建 API 密钥”。

即可得到的 SecretID 和 SecretKey 值.

如何安装 Minio Client 工具?

macOS 安装 Minio Client

brew install minio/stable/mc
mc --help

Linux 安装 Minio Client

wget https://dl.minio.io/client/mc/release/linux-amd64/mc
chmod +x mc
cp mc /usr/bin
mc --help

如何配置滴滴云 Minio Client?

获取到 S3 API 密钥后,得到 SecretID 和 SecretKey 值,通过这两个值来配置滴滴云 S3。

公共配置信息如下:

mc config host add didiyuns3 https://s3.didiyunapi.com AKDD002DYS7H379X1YQKZFSCGOFNX1 V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12

DC2 配置信息如下:

mc config host add didiyuns3 https://s3-internal.didiyunapi.com AKDD002DYS7H379X1YQKZFSCGOFNX1 V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12

配置成功后,在用户目录下 .mc/config.json 会生成新的配置信息。

{
	"version": "9",
	"hosts": {
		"didiyuns3": {
			"url": "https://s3-gz.didiyunapi.com",
			"accessKey": "AKDD002DYS7H379X1YQKZFSCGOFNX1",
			"secretKey": "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12",
			"api": "s3v4",
			"lookup": "auto"
		}
	}
}

如何使用的 Minio Client?

查询滴滴云 S3 上的所有 Bucket

➜  ~ mc ls didiyuns3
[2018-02-09 15:08:04 CST]     0B didiyun/

查询滴滴云 S3上 某 Bucket 的文件列表

➜  ~ mc ls didiyuns3/didiyun
[2018-11-04 10:57:03 CST] 107KiB 6a6f178b009847dca.jpg
[2018-10-31 10:24:09 CST]    40B test
[2018-08-30 15:50:07 CST]  13MiB test.mp4
[2018-08-24 09:59:25 CST] 107KiB test_6a6f178b009847163649c7cb9s
[2018-12-10 17:49:36 CST]     0B test/

上传文件到滴滴云 S3 上

➜  ~ mc cp ./test1 didiyuns3/didiyun/
./test1:  40 B / 40 B ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100.00% 296 B/s 0s
➜  ~ mc ls didiyuns3/didiyun
[2018-11-04 10:57:03 CST] 107KiB 6a6f178b009847163649c7cb96a9e4ca.jpg
[2018-11-13 17:56:44 CST] 3.1KiB das.graffle
[2018-10-31 10:24:09 CST]    40B test
[2018-08-30 15:50:07 CST]  13MiB test.mp4
[2018-12-10 17:52:30 CST]    40B test1
[2018-08-24 09:59:25 CST] 107KiB test_6a6f178b009847163649c7cb96a9e4ca
[2018-12-10 17:53:39 CST]     0B test/

使用 MC CP 上传成功后,再重新获取到列表就会多出 test1 文件。

下载滴滴云 S3 上的文件到本地

➜  ~ mc cp didiyuns3/didiyun/test1 ./
...gz.didiyunapi.com/didiyun/test1:  40 B / 40 B  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100.00% 109 B/s 0s

更多指令请使用 Help

➜  ~ mc help
NAME:
  mc - Minio Client for cloud storage and filesystems.

USAGE:
  mc [FLAGS] COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]

COMMANDS:
  ls       List files and folders.
  mb       Make a bucket or a folder.
  cat      Display file and object contents.
  pipe     Redirect STDIN to an object or file or STDOUT.
  share    Generate URL for sharing.
  cp       Copy files and objects.
  mirror   Mirror buckets and folders.
  find     Search for files and objects.
  select   Run select queries on objects.
  stat     Stat contents of objects and folders.
  diff     List differences in object name, size, and date between folders.
  rm       Remove files and objects.
  events   Manage object notifications.
  watch    Watch for file and object events.
  policy   Manage anonymous access to objects.
  admin    Manage Minio servers
  session  Manage saved sessions for cp command.
  config   Manage mc configuration file.
  update   Check for a new software update.
  version  Print version info.

GLOBAL FLAGS:
  --config-folder value, -C value  Path to configuration folder. (default: "/Users/didi/.mc")
  --quiet, -q                      Disable progress bar display.
  --no-color                       Disable color theme.
  --json                           Enable JSON formatted output.
  --debug                          Enable debug output.
  --insecure                       Disable SSL certificate verification.
  --help, -h                       Show help.

VERSION:
  2018-10-18T00:40:05Z

你可能感兴趣的:(云计算,数据库,S3存储,对象存储,滴滴云)