All Products
Search
Document Center

Object Storage Service:appendfromfile

Last Updated:Apr 09, 2024

This topic describes how to run the appendfromfile command to append content to an appendable object in Object Storage Service (OSS).

Usage notes

  • To perform an append upload, you must have the oss:GetObject and oss:PutObject permissions. For more information, see Attach a custom policy to a RAM user.

  • This topic provides sample command lines that 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 command reference.

Command syntax

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

The following table describes the parameters in the syntax.

Parameter

Description

localfilename

The full path of the local file that you want to upload.

bucketname

The name of the bucket.

objectname

The name of the object to which you want to append content. When you run the appendfromfile command to perform an 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".

After you configure metadata for the object, you can run the set-meta command to modify the metadata of the object.

Examples

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

  1. Run the following command to upload exampleobject.txt and 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"

    The following sample output indicates that the local file is uploaded to the bucket and stored as the exampleobject.txt object. The size of the exampleobject.txt object 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, 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

    The following sample output indicates that content is appended to exampleobject.txt and that the object size after the append upload operation is 150 bytes.

    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, 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 file in an append upload to the examplebucket bucket that is located in the China (Shanghai) region and 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 common options, see Common options.