Ans*_*med 8 csv google-cloud-storage google-cloud-platform google-cloud-functions
我正在使用谷歌云功能在谷歌云存储上创建一个 CSV 文件。现在我想编辑该文件 - 是否可以在该文件中附加数据?如果是,那么如何?
Thi*_*lvo 13
Google Cloud Storage is the Object Storage managed service for Google Cloud Platform. Unlike a block storage or file system storage, objects stored are immutable.
As mentioned in official doc :
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 Cloud Storage, and doing so happens atomically — until the new upload completes the old version of the object will be served to readers, and after the upload completes the new version of the object will be served to readers. 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.
作为一种解决方法,我们可以考虑将多个文件上传到一个存储桶,然后通过组合所有以前的文件来创建一个新对象。
gsutil compose gs://bucket/obj1 [gs://bucket/obj2 ...] gs://bucket/composite
Run Code Online (Sandbox Code Playgroud)
请注意,此compose
命令也可通过JSON API
以下方式获得:
POST https://storage.googleapis.com/storage/v1/b/bucket/o/destinationObject/compose
Run Code Online (Sandbox Code Playgroud)
并通过云存储客户端库
所以这个调用可以很容易地集成到你的代码中。请务必在需要的角色之前授予访问存储桶的权限。
归档时间: |
|
查看次数: |
5794 次 |
最近记录: |