cp

Copies a local file or Storj object to another location locally or in Storj

Usage

Windows
Linux
macOS
Windows
./uplink.exe cp [flags] <SOURCE> <DESTINATION>
Linux
uplink cp [flags] <SOURCE> <DESTINATION>
macOS
uplink cp [flags] <SOURCE> <DESTINATION>

The cp command is used to upload and download objects. The cp command abstracts the complexity of encryption, erasure coding, and distributing pieces of a file to storage nodes.

Flags

Flag

Description

--access string

the serialized access, or name of the access to use

--expires string

optional expiration date of an object. Please use format (yyyy-mm-ddThh:mm:ssZhh:mm)

--help, -h

help for cp

--metadata string

optional metadata for the object. Please use a single level JSON object of string to string only

--progress

if true, show progress (default true)

Examples

Copy a local file into an existing bucket

When the cpm command is used to copy a file to Storj DCS (upload), the CLI first encrypts the file client-side, then splits it into a minimum of x erasure-coded pieces, and finally, the x pieces are uploaded in parallel to x different storage nodes. x currently equals 80 but is subject to change depending on continuous optimization.

To copy cheesecake.jpg into the existing bucket cakes, use the following command:

Windows
Linux
macOS
Windows
./uplink.exe cp cheesecake.jpg sj://cakes
Linux
uplink cp cheesecake.jpg sj://cakes
macOS
uplink cp cheesecake.jpg sj://cakes

You cannot use regular expressions to specify which files to copy (e.g. uplink cp cheese* sj://cakes will not work). Also, you can only specify one source at a time (no uplink cp cheesecake.jpg cheesecake.png sj://cakes)

Output:

Copy a file from a bucket to a local drive

When the cp command is used to copy a file from Storj DCS (download), the CLI first downloads the minimum number of pieces to reconstitute a file (typically 29 pieces), then re-encodes the pieces into a single file, and finally decrypts the file client-side.

To copy a file from a project to a local drive, use:

Windows
Linux
macOS
Windows
./uplink.exe cp sj://cakes/cheesecake.jpg ~/Downloads/
Linux
uplink cp sj://cakes/cheesecake.jpg ~/Downloads/
macOS
uplink cp sj://cakes/cheesecake.jpg ~/Downloads/

Copy a local file into a bucket with an expiration date

The uploaded object can be set to expire at a certain time. After the expiration date, the file is no longer available and no longer will generate usage charges. To set an expiration date for a file when uploading it, you should use the cp command with the --expires flag:

Windows
Linux
macOS
Windows
./uplink.exe cp cheesecake.jpg --expires 2021-12-31T13:00:00+02:00 sj://cakes
Linux
uplink cp cheesecake.jpg --expires 2021-12-31T13:00:00+02:00 sj://cakes
macOS
uplink cp cheesecake.jpg --expires 2021-12-31T13:00:00+02:00 sj://cakes

The date is given in the yyyy-mm-ddThh:mm:ssZhh:mm format defined in ISO 8601. 2021-12-31T13:00:00+02:00 reads "December, 31st at 1pm UTC+2". A date ending with "Z", such as 2021-12-31T13:00:00Z, is in UTC.

The command above gives the following output:

Copy a file to a bucket with metadata

You can include metadata when uploading your file using the --metadata flag. These metadata are provided in JSON format.

You must use a single level JSON object of string to string only (e.g. '{"key1":"value1", "key2": "value2"'}

For example, to include information about the baker of a cheesecake and the author of the photo:

Windows
Linux
macOS
Windows
./uplink.exe cp cheesecake.jpg sj://cakes --metadata '{\"baker\":\"cheeseman\", \"picture_author\": \"picman\"}'
Linux
uplink cp cheesecake.jpg sj://cakes --metadata '{"baker":"cheeseman", "picture_author": "picman"}'
macOS
uplink cp cheesecake.jpg sj://cakes --metadata '{"baker":"cheeseman", "picture_author": "picman"}'

You can retrieve these metadata using the meta get command.