All Products
Search
Document Center

Object Storage Service:cp (upload files)

Last Updated:Nov 20, 2025

Use the ossutil cp command to upload local resources such as files, images, and videos to OSS. You can also use this command to upload large files.

Notes

  • To upload files, you must have the oss:PutObject, oss:ListParts, and oss:AbortMultipartUpload permissions. For more information, see Grant custom access policies to RAM users.

  • Batch upload is supported only when the source is a folder.

Command format

ossutil cp source dest [flags]

Parameter

Type

Description

source

string

The path of the local file. Relative paths, absolute paths, and - are supported. If you specify -, data is read from standard input.

dest

string

The path of the object in the destination bucket. Example: oss://bucket[/prefix].

--acl

string

The access permissions of the object. Valid values:

  • private: private.

  • public-read: public-read.

  • public-read-write: public-read-write.

  • default: inherits from the bucket.

--bandwidth-limit

SizeSuffix

Limits the network bandwidth to control the data transfer rate. The minimum value is 1024 B/s. The default unit is B/s.

When you configure this parameter, you can specify a unit for the bandwidth value as needed. Valid units include B (bytes), K (kilobytes), M (megabytes), and G (gigabytes). For example, 50 M specifies a bandwidth limit of 50 MB/s.

--bigfile-threshold

SizeSuffix

The threshold to enable multipart upload, download, or copy for large files. The default value is 104857600.

--cache-control

string

Specifies the caching behavior of the webpage when the object is downloaded.

--content-disposition

string

Specifies how the object is displayed.

--content-encoding

string

Declares the encoding method of the object.

--content-type

string

The content type of the object.

--copy-props

string

Determines which properties are uploaded from the source object. Valid values:

  • none

  • metadata

  • default

--checkpoint-dir

string

  • If you do not specify a directory for resumable operations, the resumable upload feature is disabled.

  • If you specify a directory, the resumable upload feature is enabled. The checkpoint file is saved to the .ossutil_checkpoint subdirectory within the specified directory.

-d, --dirs

string

Returns the files and subdirectories in the current folder, instead of recursively displaying all files in all subdirectories.

--encoding-type

string

The encoding type of the input object name or file name. Valid value: url.

--end-with

string

Returns objects that are alphabetically before or at the specified value.

--exclude

stringArray

The exclusion rules for paths or file names.

--exclude-from

stringArray

Reads exclusion rules from a rule file.

--expires

stringArray

Specifies the absolute expiration time for the cached content.

--files-from

stringArray

Reads a list of source file names from a file. Empty lines or comment lines are ignored.

--files-from-raw

stringArray

Reads a list of source file names from a file.

--filter

stringArray

The filtering rules for paths or file names.

--filter-from

stringArray

Reads filtering rules from a rule file.

-f, --force

/

Forces the operation without a confirmation prompt.

--include

stringArray

The inclusion rules for paths or file names.

Note

For more information about filtering options, see Filtering options.

--include-from

stringArray

Reads inclusion rules from a rule file.

-j, --job

int

The number of concurrent tasks. The default value is 3.

Note

This parameter takes effect only when you specify the -f, --update, --size-only, or --ignore-existing parameter.

--listObjects

/

Uses the ListObjects API operation to list objects.

--max-size

SizeSuffix

The maximum size of a file to transfer. The default unit is byte. You can also use suffixes such as B, K, M, G, T, or P. 1 K (KiB) = 1024 B.

--metadata

strings

Specifies the user metadata of the object. Use the key=value format.

--metadata-directive

string

Specifies how to set the metadata of the destination object. Valid values:

  • COPY

  • REPLACE

--metadata-exclude

stringArray

The exclusion rules for object metadata.

--metadata-filter

stringArray

The filtering rules for object metadata.

--metadata-filter-from

stringArray

Reads object metadata filtering rules from a rule file.

--metadata-include

stringArray

The inclusion rules for object metadata.

--min-age

Duration

Uploads only files modified before the specified time interval. The default unit is second. You can use a suffix for the unit. For example, 1h specifies 1 hour.

Note

--min-age 1h specifies that only files modified 1 hour ago or earlier are uploaded.

--max-age

Duration

Uploads only files modified within the specified time interval. The default unit is second. You can use a suffix for the unit. For example, 1h specifies 1 hour.

Note

--max-age 1h specifies that only files modified within the last hour are uploaded.

--min-mtime

Time

Uploads only files modified after the specified time. The time must be in UTC format. Example: 2006-01-02T15:04:05.

Note

--min-mtime "2006-01-02T15:04:05" specifies that only files modified after 15:04:05 on January 2, 2006 are uploaded.

--max-mtime

Time

Uploads only files modified before the specified time. The time must be in UTC format. Example: 2006-01-02T15:04:05.

--min-size

SizeSuffix

The minimum size of a file to transfer. The default unit is byte. You can also use suffixes such as B, K, M, G, T, or P. 1 K (KiB) = 1024 B.

--no-progress

/

Does not display the progress bar.

--page-size

int

The maximum number of objects to list per page during a batch upload. The default value is 1000. The value must be between 1 and 1000.

--parallel

int

The number of concurrent tasks for operations on a single file.

--part-size

SizeSuffix

The part size. By default, ossutil calculates an appropriate part size based on the file size. The value must be between 100 KiB and 5 GiB.

-r, --recursive

/

Performs the operation recursively. If you specify this option, the command is run on all matching objects in the bucket. Otherwise, the command is run only on the object specified by the path.

--request-payer

string

The payment method for the request. Set this parameter if you use the pay-by-requester mode. Valid value: requester.

--size-only

/

Uploads only source files whose sizes are different from the destination files.

--storage-class

string

The storage class of the object. Valid values:

  • Standard: Standard

  • IA: IA storage class

  • Archive: Archive Storage

  • ColdArchive: Cold Archive

  • DeepColdArchive: Deep Cold Archive

--tagging

strings

Specifies the tags of the object. Use the key=value format.

--tagging-directive

string

Specifies how to set the tags of the destination object. Valid values:

  • COPY

  • REPLACE

-u, --update

/

Uploads only source files that are newer than the destination files.

--ignore-existing

/

Skips destination files that already exist.

Note

For more information, see Command-line options.

The naming conventions for destination objects are as follows:

  • When you upload a single file, if the prefix is empty, the object name is the file name.

  • When you upload a single file, if the prefix ends with a forward slash (/), the object name is prefix + file name.

  • When you perform a batch upload, if the prefix is empty, the object name is the relative path of the source file.

  • When you perform a batch upload, if the prefix ends with a forward slash (/), the object name is prefix + relative path of the source file.

  • When you perform a batch upload, if the prefix does not end with a forward slash (/), the object name is prefix + / + relative path of the source file.

Note

The relative path of a source file is the name that follows the root directory. For example, when you run `cp /root/dir/ ...`, the relative path of the file `/root/dir/subdir/test.txt` is `subdir/test.txt`.

Usage examples

Upload a single file

  • Uploading a single file

    Upload the local file examplefile.txt to the desfolder folder in the examplebucket bucket.

    ossutil cp D:/localpath/examplefile.txt oss://examplebucket/desfolder/

Upload multiple files

  • Upload only the files in a folder

    Upload the files from the local folder localfolder to the desfolder folder in the examplebucket bucket.

    ossutil cp -r D:/localpath/localfolder/ oss://examplebucket/desfolder/
  • Batch upload files that meet specific conditions

    Upload all files in TXT format.

    ossutil cp -r D:/localpath/localfolder/ oss://examplebucket/desfolder/ --include "*.txt"
  • Use 10 concurrent tasks to batch upload files

    ossutil cp -r D:/localpath/localfolder/ oss://examplebucket/desfolder/ -f -j 10

Limit the upload speed

  • Upload the local file upload.rar to the desfolder folder in the examplebucket bucket at a speed of 20 MB/s. The default unit is bytes per second (B/s).

    ossutil cp D:/upload.rar oss://examplebucket/desfolder/ --bandwidth-limit 20971520
  • Upload the local file file.rar to the desfolder folder in the examplebucket bucket and limit the upload speed to 50 MB/s. The unit is specified as megabytes per second (MB/s).

    ossutil cp D:/file.rar oss://examplebucket/desfolder/ -r --bandwidth-limit 50M