upload

Prev Next

Available in Classic and VPC

Upload the specified file or directory to a container (bucket).

Note

If you upload in segments using --segment-size, the segments are stored in a separate container from the manifest. If you do not enter --segment-container, the <container>_segments container is automatically created. Downloads are performed from the container where the manifest was uploaded.

Syntax

The upload syntax is as follows:

swift upload \
    <container> \
    <file-or-directory> \
    [--object-name <object-name>] \
    [--segment-size <size>] \
    [--segment-container <container>] \
    [--use-slo] \
    [--use-dlo] \
    [--leave-segments] \
    [--changed] \
    [--skip-identical] \
    [--skip-container-put] \
    [--ignore-checksum] \
    [--object-threads <threads>] \
    [--segment-threads <threads>] \
    [--meta <name:value>] \
    [--header <header:value>]

Options

This section describes the options available when running upload.

Required options

The following options are required for upload.

Options Type Required Description
<container> String Required Container name
<file-or-directory> List Required File or directory path
  • Multiple entries are allowed, separated by spaces.
  • When entering -, the program reads input from standard input (--object-name is required).

Optional options

These are the optional options for upload. Options that are not specified will use their default values.

Options Type Required Description
--object-name String Optional Object name
  • Used as a prefix for object names when uploading a directory
--segment-size Integer Optional Segment size for segmented upload (byte)
  • Splits the file into segments no larger than the specified size for upload and generates a manifest file.
--segment-container String Optional Name of the container to which segments will be uploaded
  • If left blank, the <container>_segments container is automatically created for upload.
--use-slo Boolean Optional Creates a static large object when used with --segment-size.
  • If the cluster supports SLO, this is applied by default, so no separate specification is necessary.
--use-dlo Boolean Optional Creates a dynamic large object when used with --segment-size.
--leave-segments Boolean Optional Retains segments from the previous manifest object when overwriting.
--changed Boolean Optional Uploads only files that have changed since the last upload.
--skip-identical Boolean Optional Does not upload files if the object matches the local file.
--skip-container-put Boolean Optional Assumes the container already exists and does not automatically create it.
--ignore-checksum Boolean Optional Disables checksum validation during upload.
--object-threads Integer Optional Number of threads to use for object upload
  • Default: 10
--segment-threads Integer Optional Number of threads to use for segment upload
  • Default: 10
--meta String Optional Metadata entry
  • Enter in name:value format.
--header String Optional Custom header to use for upload requests
  • header:value format

Common options

For information about the options common to all swift subcommands, see Archive Storage options.

Examples

If the upload request is successful, the name of the uploaded object is displayed.

Command

The following is an example command for uploading a single file.

swift upload test-container-01 sample.txt

The following is a example command for uploading an entire directory.

swift upload test-container-01 docs

The following is an example command for splitting a large file into segments and uploading them to a separate container.

swift upload test-container-01 large.bin \
    --segment-size 1048576 \
    --segment-container test-segments-01

The following is an example command for specifying an object name and setting metadata.

swift upload test-container-01 sample.txt \
    --object-name renamed.txt \
    --meta Purpose:Documentation

Output

The following is an example output for uploading a single file.

sample.txt

The following is an example output for uploading an entire directory.

docs/report.txt

The following is an example output for uploading a large file split into segments.

large.bin segment 4
large.bin segment 2
large.bin segment 0
large.bin segment 3
large.bin segment 1
large.bin

The following is an example output for uploading a file with a specified object name and metadata.

renamed.txt