Which of the following is not an operation that can be performed on a file object
This topic describes how to run the cp command to upload local files or directories to Object Storage Service (OSS). The following table describes the parameters that you can configure to run the cp command to upload objects to OSS. Default value: 104857600 (100 MB). Valid values: 0 to 9223372036854775807. Valid values: 1 to 9223372036854775807. The -j, --jobs and --parallel options in the preceding command syntax can be used to adjust performance if the default number of concurrent tasks does not meet your performance requirements. By default, ossutil calculates the number of concurrent operations based on the object size. When you upload multiple large objects, the actual number of concurrent tasks is
calculated by multiplying the number of jobs by the number of concurrent operations. In this topic, local files or directories are uploaded from a Linux system to OSS. You can modify the parameters in the examples based on your operating system and environment. This topic uses the following common examples: You can use ossutil to upload local files to OSS. The following examples show how to run the cp command to upload objects to OSS by using simple upload: If you do not specify the name of the uploaded object, the name of the local file is used as the object name. If you specify the name of the uploaded object, the object is stored in OSS based on the specified name. You can add the -r parameter to the
cp command to upload files from a local directory to a specified path of OSS. You can add the -r option to the cp command and add the name of a local directory to upload the local directory and the files inside to a specified path of OSS.
When you run the cp command to upload a local file, you can add the --meta option to the command and configure the metadata of the file in the following format:
When you resume a failed batch upload task, you can specify the --update (abbreviated as the -u) option to skip uploaded files. This way, you can upload only incremental data to OSS.
In OSS, a directory is an object that is 0 KB in size and has a name that ends with a forward slash (/). If you specify the --disable-dir-object parameter in the cp command to upload a directory, OSS does not generate an object for the uploaded directory. However, you can view the directory in the OSS console. If you delete all objects from the directory, the directory is also deleted.
Configure the maximum upload speedWhen you upload an object, you can set --maxupspeed to limit the maximum upload speed. Unit: KB/s. Examples:
Configure tagging for an object when you upload the objectWhen you run the cp command to upload an object, you can specify the --tagging option to configure tags for the object. Separate multiple tags with ampersands (&). Example:
For more information about object tagging, see object-tagging (add, modify, query, and delete object tags). Specify the storage class of an object when you upload the objectWhen you run the cp command to upload a local file, you can specify the --meta option to specify the storage class of the object. OSS supports the following storage classes:
If you do not specify the storage class in the command, the storage class of the uploaded object is the same as that of the bucket in which the object is stored. For more information, see Overview. Examples:
Specify the ACL of an object when you upload the objectWhen you run the cp command to upload objects, you can specify the --meta option to set the access control list (ACL) of the objects. OSS supports the following object ACLs:
The following examples show how to specify the ACL of objects when you run the cp command to upload objects:
Specify an encryption method for an object when you upload the objectWhen you upload an object, you can specify the server-side encryption method for the object. The object is stored in the specified bucket after the object is encrypted. Examples:
For more information about server-side encryption, see Server-side encryption. Generate snapshots for objects when you upload the objectsWhen you run the cp command to batch upload objects and specify the --snapshot-path option in the command, ossutil creates the snapshots of the uploaded objects in the specified directory to record the last modified time of the objects. In subsequent upload tasks, ossutil determines whether to skip existing objects based on their last modified time. If you want to specify the --snapshot-path option in the command, make sure that the objects in OSS are not modified by other users since the last time when the objects are uploaded. The --snapshot-path option is used to accelerate incremental batch uploads. The following example shows how to generate snapshots for objects when you run the cp command to upload the objects:
Notice
Batch upload objects that meet specified conditionsWhen you run the cp command to batch upload objects and specify the --include and --exclude options in the command, ossutil batch uploads objects that meet the specified conditions. The --include and --exclude options support the following formats:
A rule can contain multiple conditions specified by --include and --exclude. After these conditions are configured, ossutil reads each rule from left to right to obtain the final matching results. If the test.txt object exists in a directory for which conditions are specified, results are generated based on different matching rules.
Notice Conditions that include directory names such as The following examples show how to run the cp command to specify conditions to upload only objects that match the conditions:
Common optionsIf you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, you can add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account. For example, you can run the following command to upload the exampleobject.txt local file to the destfolder directory of a bucket named examplebucket. The bucket is located in the China (Shanghai) region and owned by another Alibaba Cloud account.
For more information about other common options that you can use for the cp command, see Common options. |