You can call AppendObject to append content to append objects that are uploaded.

Note Objects uploaded by calling the AppendObject operation are append objects. Objects uploaded by calling the PutObject operation are normal objects.
When you upload objects by using append upload, you must configure the correct position from which the append operation starts.
  • When you create an append object, set the position from which the append operation starts to 0.
  • When you append content to an append object, set the position from which the append operation starts to the current length of the object.

    You can obtain the length of the object from the returned message after the append upload operation or by calling HeadObject.

The following code provides an example on how to perform append upload:

// Specify the name of the bucket such as examplebucket, the full path of the object such as exampledir/exampleobject.txt, and the full path of the local file such as /storage/emulated/0/oss/examplefile.txt. 
// The full path of the object cannot contain the bucket name. 
AppendObjectRequest append = new AppendObjectRequest("examplebucket", "exampledir/exampleobject.txt", "/storage/emulated/0/oss/examplefile.txt");

ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType("text/plain");
append.setMetadata(metadata);

// Configure the position from which the append operation starts. 
append.setPosition(0);

// Configure a callback function. 
append.setProgressCallback(new OSSProgressCallback<AppendObjectRequest>() {
    @Override
    public void onProgress(AppendObjectRequest request, long currentSize, long totalSize) {
        Log.d("AppendObject", "currentSize: " + currentSize + " totalSize: " + totalSize);
    }
});
// Perform the append upload operation in the asynchronous mode. 
OSSAsyncTask task = oss.asyncAppendObject(append, new OSSCompletedCallback<AppendObjectRequest, AppendObjectResult>() {
    @Override
    public void onSuccess(AppendObjectRequest request, AppendObjectResult result) {
        Log.d("AppendObject", "AppendSuccess");
        Log.d("NextPosition", "" + result.getNextPosition());
    }

    @Override
    public void onFailure(AppendObjectRequest request, ClientException clientExcepion, ServiceException serviceException) {
        // Handle exceptions. 
    }
});

For partition storage of Android 10 and later versions, you can use the Uniform Resource Identifier (URI) of an object to upload the object to Object Storage Service (OSS).

// Specify the bucket name such as examplebucket and the full path of the object such as exampledir/exampleobject.txt. 
// The full path of the object cannot contain the bucket name. 
AppendObjectRequest append = new AppendObjectRequest("examplebucket", "exampledir/exampleobject.txt", fileUri);

ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType("text/plain");
append.setMetadata(metadata);

// Configure the position from which the append operation starts. 
append.setPosition(0);

// Configure a callback function. 
append.setProgressCallback(new OSSProgressCallback<AppendObjectRequest>() {
    @Override
    public void onProgress(AppendObjectRequest request, long currentSize, long totalSize) {
        Log.d("AppendObject", "currentSize: " + currentSize + " totalSize: " + totalSize);
    }
});
// Perform the append upload operation in the asynchronous mode. 
OSSAsyncTask task = oss.asyncAppendObject(append, new OSSCompletedCallback<AppendObjectRequest, AppendObjectResult>() {
    @Override
    public void onSuccess(AppendObjectRequest request, AppendObjectResult result) {
        Log.d("AppendObject", "AppendSuccess");
        Log.d("NextPosition", "" + result.getNextPosition());
    }

    @Override
    public void onFailure(AppendObjectRequest request, ClientException clientExcepion, ServiceException serviceException) {
        // Handle exceptions. 
    }
});