mc share 命令用来生成临时访问对象的 URL。语法如下:
C:\> mc share -h NAME: mc share - generate URL for temporary access to an object USAGE: mc share COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...] COMMANDS: download generate URLs for download access upload generate `curl` command to upload objects without requiring access/secret keys list list previously shared objects FLAGS: --config-dir value, -C value path to configuration folder (default: "C:\\Users\\Administrator\\mc") --quiet, -q disable progress bar display --no-color disable color theme --json enable JSON lines formatted output --debug enable debug output --insecure disable SSL certificate verification --help, -h show help
mc share 命令拥有三个子命令分别是 download、upload 和 list,下面将逐一介绍。
生成用于下载访问的 URL。语法如下:
C:\> mc share download -h NAME: mc share download - generate URLs for download access USAGE: mc share download [FLAGS] TARGET [TARGET...] FLAGS: --recursive, -r share all objects recursively --version-id value, --vid value share a particular object version --expire value, -E value set expiry in NN[h|m|s] (default: "168h") --config-dir value, -C value path to configuration folder (default: "C:\\Users\\Administrator\\mc") --quiet, -q disable progress bar display --no-color disable color theme --json enable JSON lines formatted output --debug enable debug output --insecure disable SSL certificate verification --help, -h show help
(1)共享此对象,默认有效期为 7 天。
D:\server\minio>mc ls local\images [2021-07-08 13:47:42 CST] 146KiB 0f78ad1e685e9e972e3780ebfbdf2192.jpeg [2021-07-03 22:23:30 CST] 180KiB 20210703221135.jpg D:\server\minio>mc share download local/images/20210703221135.jpg URL: http://127.0.0.1:9000/images/20210703221135.jpg Expire: 7 days 0 hours 0 minutes 0 seconds Share: http://127.0.0.1:9000/images/20210703221135.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=root%2F20210711%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210711T061944Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=df6d86343a1f3884a94abd85ee8933d6c10891f3461f8a080c37986d3e203813
(2)共享此对象,有效期为 10 分钟。
D:\server\minio>mc share download --expire=10m local/images/20210703221135.jpg URL: http://127.0.0.1:9000/images/20210703221135.jpg Expire: 10 minutes 0 seconds Share: http://127.0.0.1:9000/images/20210703221135.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=root%2F20210711%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210711T062042Z&X-Amz-Expires=600&X-Amz-SignedHeaders=host&X-Amz-Signature=39f7143f1e1db39c5d05ef48fa45cc652d1d111fd881ac9dc511f57bca5afa31
(3)共享此文件夹下的所有对象,有效期为 5 天。
URL: http://127.0.0.1:9000/images/20210703221135.jpg Expire: 5 days 0 hours 0 minutes 0 seconds Share: http://127.0.0.1:9000/images/20210703221135.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=root%2F20210711%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210711T072906Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=c740ab14b8faaf10d02e93577cf87e10b87c99b3065494bff86242ae715bacb2
(4)共享此存储桶下的所有对象及其所有文件夹和子文件夹,有效期为 5 天。
D:\server\minio>mc share download --recursive --expire=120h local/images/ URL: http://127.0.0.1:9000/images/0f78ad1e685e9e972e3780ebfbdf2192.jpeg Expire: 5 days 0 hours 0 minutes 0 seconds Share: http://127.0.0.1:9000/images/0f78ad1e685e9e972e3780ebfbdf2192.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=root%2F20210711%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210711T072940Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=a304577e74b887a987b922912619ba986a5cdb94ba6c127194aa9c619be8a424 URL: http://127.0.0.1:9000/images/20210703221135.jpg Expire: 5 days 0 hours 0 minutes 0 seconds Share: http://127.0.0.1:9000/images/20210703221135.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=root%2F20210711%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210711T072940Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=5ef33915f7563d562e01f2794fb4e5e8a8ecd00ff303f474849f865fb00a7fbc
生成 `curl` 命令来上传对象而不需要访问/密钥。语法如下:
C:\> mc share upload -h NAME: mc share upload - generate `curl` command to upload objects without requiring access/secret keys USAGE: mc share upload [FLAGS] TARGET [TARGET...] FLAGS: --recursive, -r recursively upload any object matching the prefix --expire value, -E value set expiry in NN[h|m|s] (default: "168h") --content-type value, -T value specify a content-type to allow --config-dir value, -C value path to configuration folder (default: "C:\\Users\\Administrator\\mc") --quiet, -q disable progress bar display --no-color disable color theme --json enable JSON lines formatted output --debug enable debug output --insecure disable SSL certificate verification --help, -h show help
(1)生成 curl 命令以允许对单个对象进行上传访问,命令在 7 天后过期(默认)。
D:\server\minio>mc share upload local/images/20210703221135.jpg URL: http://127.0.0.1:9000/images/20210703221135.jpg Expire: 7 days 0 hours 0 minutes 0 seconds Share: curl http://127.0.0.1:9000/images/ -F x-amz-credential=root/20210711/us-east-1/s3/aws4_request -F x-amz-date=20210711T073436Z -F x-amz-signature=cc77b2ea72752e0576a0c8eb58fac0864f53d60f1f0d93a4377a37ca7280fd73 -F bucket=images -F policy=eyJleHBpcmF0aW9uIjoiMjAyMS0wNy0xOFQwNzozNDozNi4xNzVaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIkYnVja2V0IiwiaW1hZ2VzIl0sWyJlcSIsIiRrZXkiLCIyMDIxMDcwMzIyMTEzNS5qcGciXSxbImVxIiwiJHgtYW16LWRhdGUiLCIyMDIxMDcxMVQwNzM0MzZaIl0sWyJlcSIsIiR4LWFtei1hbGdvcml0aG0iLCJBV1M0LUhNQUMtU0hBMjU2Il0sWyJlcSIsIiR4LWFtei1jcmVkZW50aWFsIiwicm9vdC8yMDIxMDcxMS91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0Il1dfQ== -F x-amz-algorithm=AWS4-HMAC-SHA256 -F key=20210703221135.jpg -F file=@<FILE>
(2)生成 curl 命令以允许上传对文件夹的访问。 命令在 120 小时后到期。
C:\> mc share upload --expire=120h s3/backup/2007-Mar-2/
(3)生成 curl 命令以允许仅将“.png”图像上传到文件夹。 命令将在 2 小时后到期。
C:\> mc share upload --expire=2h --content-type=image/png s3/backup/2007-Mar-2/
(4)生成 curl 命令以允许上传访问与键前缀“backup/”匹配的任何对象。 命令将在 2 小时后到期。
C:\> mc share upload --recursive --expire=2h s3/backup/2007-Mar-2/backup/
列出以前共享的对象。语法如下:
C:\> mc share list -h NAME: mc share list COMMAND - list previously shared objects USAGE: mc share list COMMAND COMMAND: upload: list previously shared access to uploads. download: list previously shared access to downloads.
(1)列出以前共享的、尚未过期的下载。
C:\> mc share list download
(2)列出以前共享的尚未过期的上传。
C:\> mc share list upload