node.js - 如何使用 Node.JS 从 GCS 存储桶中读取删除的过期时间?
问题描述
我已将 GCS 存储桶配置为在 20 天后自动删除存储在其中的对象(通过 GCP Web UI 执行此操作)。当我在 Node.JS 中引用存储桶对象时,如何获取它配置为老化的天数?
GCS 生命周期参考在这里,但不提供示例。
解决方案
您是否尝试过使用addLifecycleRule
方法并设置存储桶策略?
@example
* const {Storage} = require('@google-cloud/storage');
* const storage = new Storage();
* const bucket = storage.bucket('bucket-name');
*
* //-
* // Automatically have an object deleted from this bucket
* // of age.
* //-
* bucket.addLifecycleRule({
* action: 'delete',
* condition: {
* age: 20 // Specified in days.
* }
* }, function(err, apiResponse) {
* if (err) {
* // Error handling omitted.
* }
推荐阅读
- postfix-mta - DD-WRT Build 杀死 Postfix Rewrite
- reactjs - 组件未从作为道具传入的对象呈现页面上的任何值
- javascript - 如何使用 JavaScript 淡化循环?
- python - 如何在 PYSPIDER 中设置同时请求数
- docker - 上次 Ubuntu 18.04 更新后损坏的 Docker
- python - 标签 python 的不一致使用
- mysql - 最高总工资
- objective-c - 如何使用可以键入图像的 Objective-C 制作自定义键盘
- ruby-on-rails - 无法在 Rails 应用程序上启动克隆的 ruby - RubyMine
- javascript - 如何在数组中找到素数?