mc share upload

The mc share upload command generates a temporary presigned URL with integrated access credentials for uploading objects to a AIStor bucket. The temporary URL expires after a configurable time limit.

Applications can perform a PUT to upload an object using the URL.

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

Syntax

ALIAS

Required The alias of a AIStor deployment and the full path to the object for which to generate an upload URL. For example:

mc share upload play/mybucket/object.txt

You can specify multiple objects on the same or different AIStor deployments. For example:

mc share upload play/mybucket/object.txt play/mybucket/otherobject.txt

If specifying the path to a bucket or bucket prefix, you must also specify the --recursive argument. For example:

mc share upload --recursive play/mybucket/

mc share upload --recursive play/mybucket/myprefix/

--expire

Alias: -E

Optional Set the expiration time limit for all generated URLs.

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

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

--recursive

Alias: -r

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

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

Replace <FILE> with the path to the file to upload. Replace <NAME> with the object name once uploaded. This may include prefixes.

Global Flags

This command supports any of the global flags.

Examples

Generate a URL to Upload Object(s)

Upload Single Object

Use mc share upload to generate a URL that supports POST requests for uploading a file to a specific object location on a AIStor deployment:

mc share upload --expire DURATION ALIAS/PATH
  • Replace ALIAS with the alias of the AIStor deployment.
  • Replace PATH with the path to the object on the AIStor deployment.
  • Replace DURATION with the duration after which the URL expires. For example, to set a 30 day expiry, specify 30d.

Upload Multiple Objects

Use mc share upload with the --recursive and --expire options to generate a temporary URL that supports POST requests for uploading files to a bucket on a AIStor deployment:

mc share upload --recursive --expire DURATION ALIAS/PATH
  • Replace ALIAS with the alias of the AIStor deployment.
  • Replace PATH with the path to the bucket or bucket prefix on the AIStor deployment.
  • 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 object in the bucket. This may include prefixes.

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=mybucket -F key=photos/${file} -F file=@${file}
done

This example will upload each file in the directory ~/Documents/photos/ to the mybucket bucket under the prefix photos. Defer to the documented best practices for your preferred scripting language for iterating through files in a directory.

Behavior

S3 Compatibility

The mc commandline tool is built for compatibility with the AWS S3 API and is tested with AIStor and AWS S3 for expected functionality and behavior.

AIStor provides no guarantees for other S3-compatible services, As their S3 API implementation is unknown and therefore unsupported.

While mc commands may work as documented, any such usage is at your own risk.