Welcome to the upcoming version of the MinIO Documentation! The content on this page is under active development and may change at any time. If you can't find what you're looking for, check our legacy documentation. Thank you for your patience.

mc share

Description

The mc share command generates temporary URLs with integrated access credentials for uploading or downloading objects to an S3-compatible host. The temporary URL expires after a configurable time limit.

For more information on shareable object URLs, see the Amazon S3 documentation on Pre-Signed URLs.

Examples

Generate a CURL GET Command

Use mc share download to generate a URL that supports GET requests for an object:

mc share download --expire DURATION ALIAS/PATH
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the object on the S3-compatible host.

  • Replace DURATION with the duration after which the URL expires. For example, to set a 30 day expiry, specify 30d.

Use mc share download with the --recursive option to generate a URL for each object in a bucket. Each URL supports GET requests for its associated object:

mc share download --recursive --expire DURATION ALIAS/PATH
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the bucket or bucket prefix on the S3-compatible host.

  • Replace DURATION with the duration after which the URL expires. For example, to set a 30 day expiry, specify 30d.

Generate a CURL POST Command

Use mc share upload to generate a URL that supports POST requests for uploading a file to a specific object location on an S3-compatible host:

mc share upload --expire DURATION ALIAS/PATH
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the object on the S3-compatible host.

  • Replace DURATION with the duration after which the URL expires. For example, to set a 30 day expiry, specify 30d.

Use mc share upload with the --recursive option to generate a URL that supports POST requests for uploading files to a bucket on an S3-compatible host:

mc share upload --recursive --expire DURATION ALIAS/PATH
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to the bucket or bucket prefix on the S3-compatible host.

  • Replace DURATION with the duration after which the URL expires. For example, to set a 30 day expiry, specify 30d.

The command returns a CURL command for uploading an object to the specified bucket prefix.

  • Replace the <FILE> string in the returned CURL command with the path to the file to upload.

  • Replace the <NAME> string in the returned CURL command with the name of the file in the bucket.

You can use a shell script loop to recursively upload the contents of a filesystem directory to the S3-compatible service:

#!/bin/sh

for file in ~/Documents/photos/
do
   curl https://play.min.io/mybucket/ \
   -F policy=AAAAA -F x-amz-algorithm=AWS4-HMAC-SHA256 \
   -F x-amz-credential=AAAA/us-east-1/s3/aws4_request \
   -F x-amz-date=20200812T202556Z \
   -F x-amz-signature=AAAA \
   -F bucket=rkbucket -F key=mydata/${file} -F file=@${file}

done

Defer to the documented best practices for your preferred scripting language for iterating through files in a directory.

Syntax

mc share download

Generates a URL for using an HTTP GET request to retrieve the object(s).

download has the following syntax:

mc share download [FLAGS] TARGET [TARGET ...]

download supports the following arguments:

TARGET

The full path to the object for which mc share download generates a URL.

If any TARGET specifies a path to a bucket, mc share must include the mc share download --recursive argument.

--recursive, --r

Recursively generate URLs for all objects in a mc share download TARGET bucket or bucket prefix.

Required if any TARGET specifies a path to a bucket or bucket prefix.

--version-id, --vid

Directs mc share download to operate only on the specified object version.

--version-id requires that the specified --TARGET be an S3-compatible service that supports Bucket Versioning. For MinIO deployments, use mc version to enable or disable bucket versioning.

--expire, --E

Set the expiration time limit for all generated URLs.

Specify a string with format ##h##m##s format. For example: 12h34m56s for an expiry of 12 hours, 34 minutes, and 56 seconds after URL generation.

Defaults to 168h or 168 hours (7 days).

upload

Generates a CURL command for uploading object(s) using HTTP POST.

upload has the following syntax:

mc share upload [FLAGS] TARGET [TARGET ...]

upload supports the following arguments:

TARGET

The full path to the object for which mc share upload generates a URL.

If the TARGET specifies a single object, mc share upload names the uploaded object based on the name specified to TARGET.

If the TARGET specifies a path to a bucket or bucket prefix, mc share upload must include the --recursive argument.

--recursive, --r

Modifies the CURL URL to support uploading objects to a bucket or bucket prefix. Required if any TARGET specifies a path to a bucket or bucket prefix. The modified CURL output resembles the following:

curl ... -F key=TARGET/<NAME> -F file=@<FILE>

Replace <FILE> with the path to the file to upload.

Replace <NAME> with the file once uploaded.

--expire, --E

Set the expiration time limit for all generated URLs.

Specify a string with format ##h##m##s format. For example: 12h34m56s for an expiry of 12 hours, 34 minutes, and 56 seconds after URL generation.

Defaults to 168h or 168 hours (7 days).

list

List all unexpired upload or download URLs generated by mc share download and mc share upload.

list has the following syntax:

mc share list SUBCOMMAND

download supports the following subcommands:

upload

List all unexpired URLs generated by mc share upload.

download

List all unexpired URLs generated by mc share download.