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

 mobiledu2502929447 发布于 2023-02-07 10:10

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?

norlesh.. 13

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.


Ezequiel Mun.. 9

虽然Google云端存储对象是不可变的,但如果您需要进行有限的追加,可以帮助您:对象撰写

此操作基本上以新名称连接同一存储桶中的多个对象的内容,cat file1 file2 > newfile但不重写数据.

因此,您可以创建一个新对象,上传要附加到其中的内容,然后关闭并随后compose在主文件末尾添加此新文件.

需要注意的是:每个对象最多允许1024个"块",并且组合自身组合的对象计为组成原始块(因此您不能通过迭代合成来欺骗限制).

2 个回答
  • 虽然Google云端存储对象是不可变的,但如果您需要进行有限的追加,可以帮助您:对象撰写

    此操作基本上以新名称连接同一存储桶中的多个对象的内容,cat file1 file2 > newfile但不重写数据.

    因此,您可以创建一个新对象,上传要附加到其中的内容,然后关闭并随后compose在主文件末尾添加此新文件.

    需要注意的是:每个对象最多允许1024个"块",并且组合自身组合的对象计为组成原始块(因此您不能通过迭代合成来欺骗限制).

    2023-02-07 10:13 回答
  • 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.

    2023-02-07 10:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有