This topic describes how to run the appendfromfile command to append content to an object that is uploaded by using append upload.

Important
  • Sample command lines in this topic are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil.
  • For more information about append upload, see Append upload.

Command syntax

./ossutil64 appendfromfile localfilename oss://bucketname/objectname [--meta ]

The following table describes the parameters that you can configure when you run the appendfromfile command.

ParameterDescription
localfilenameThe full path of the local file that you want to upload.
bucketnameThe name of the bucket that stores the object to which you want to append content.
objectnameThe name of the object to which you want to append content. When you run the appendfromfile command for append upload, you can retain the original name of the local file for the object or specify another name.
--metaThe metadata of the object. You can configure this parameter only the first time you run the appendfromfile command to upload an object. Example: --meta "x-oss-object-acl:private".

For objects whose metadata is configured, you can run the set-meta (manage object metadata) command to modify their metadata.

Examples

In the following examples, the appendfromfile command is first used to upload a local file named exampleobject.txt in the root directory to a bucket named examplebucket. Then, the appendfromfile command is used to append content to exampleobject.txt multiple times.

  1. Run the following command to upload exampleobject.txt, and then set the access control list (ACL) of the uploaded object to private:
    ./ossutil64 appendfromfile exampleobject.txt oss://examplebucket/exampleobject.txt --meta "x-oss-object-acl:private"

    If a similar output is displayed, exampleobject.txt is uploaded to the specified bucket and the object size is 5 bytes.

    total append 5(100.00%) byte,speed is 0.00(KB/s)
    local file size is 5,the object new size is 5,average speed is 0.04(KB/s)
  2. Run the following command to append the content of a file named dest.txt to exampleobject.txt.

    If you want to append more content to exampleobject.txt, run the following command and replace dest.txt with the name of the file whose content you want to append to exampleobject.txt:

    ./ossutil64 appendfromfile dest.txt oss://examplebucket/exampleobject.txt

    If a similar output is displayed, the content is appended to exampleobject.txt. The object size becomes 150 bytes after the append upload.

    total append 150(100.00%) byte,speed is 0.00(KB/s)
    local file size is 150,the object new size is 150,average speed is 1.19(KB/s)

Common options

If 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 a file named exampleobject.txt to a bucket named examplebucket, which is located in the China (Shanghai) region and is owned by another Alibaba Cloud account:
./ossutil64 appendfromfile exampleobject.txt oss://examplebucket/exampleobject.txt -e shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA****  -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about other options that you can use for the appendfromfile command, see Common options.