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

Notice
  • 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.

Parameter Description
localfilename The full path of the local file that you want to upload.
bucketname The name of the bucket that stores the object to which you want to append content.
objectname The 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.
--meta The 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 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 a different region, you can use the -e option to specify the endpoint of the region in which the specified bucket resides. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, you can use the -i option to specify the AccessKey ID of the specified account, and use the -k option 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.