google-app-enginegoogle-cloud-storage

How to append write to google cloud storage file from app engine?


This deprecated API supports appending content to google cloud storage file:

FileWriteChannel FileService.openWriteChannel(AppEngineFile file,
                                boolean lock)

But,

GcsOutputChannel GcsService.createOrReplace(GcsFilename filename,
                               GcsFileOptions options)

doesn't seem so.

What is the solution here?


Solution

  • Sorry to tell you but it cannot be done without replacing the file each time.

    As stated in the Cloud Services docs Under Object immutability

    Objects are immutable, which means that an uploaded object cannot change throughout its storage lifetime. An object's storage lifetime is the time between successful object creation (upload) and successful object deletion. In practice, this means that you cannot make incremental changes to objects, such as append operations or truncate operations. However, it is possible to overwrite objects that are stored in Google Cloud Storage because an overwrite operation is in effect a delete object operation followed immediately by an upload object operation. So a single overwrite operation simply marks the end of one immutable object's lifetime and the beginning of a new immutable object's lifetime.