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
andoss:PutObject
permissions. For more information, see Attach a custom policy to a RAM user.For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.
For more information about append uploads, see Append upload.
Command syntax
ossutil 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 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 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: |
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.
Run the following command to upload exampleobject.txt and set the access control list (ACL) of the uploaded object to private:
ossutil 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)
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:
ossutil 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:
ossutil appendfromfile exampleobject.txt oss://examplebucket/exampleobject.txt -e shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA**** -k 67DLVBkH7EamOjy2W5RVAHUY9H****
For more information about common options, see Common options.