列出在特定时间戳记之后在Google Cloud Storage Bucket中更改的文件 [英] List files changed after a particular timestamp in Google Cloud Storage Bucket
问题描述
我想列出在node.js中的特定时间戳记后在Google Cloud Storage Bucket中已更改/添加的文件.我正在浏览文档 https://cloud.google.com/storage/docs/how -to ,但没有找到任何机制.
I want to list the files that have changed/added in a Google Cloud Storage Bucket after a particular timestamp in node.js. I was going through documentation https://cloud.google.com/storage/docs/how-to but did not find any mechanism for it.
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
const bucketName = 'my-bucket';
const [files] = await storage.bucket(bucketName).getFiles();
如何列出在存储桶中添加了时间戳后添加的文件?
How can files be listed which were added after a timestamp in a bucket?
推荐答案
This doesn't appear to be possible with the given list API. The documentation doesn't say anything about filtering objects with a date.
将有关所有上载文件的数据存储在数据库中是很常见的,这可以更轻松地查询要存储的文件的任何属性.您甚至可以使用Cloud Functions触发器为每次上传的文件自动将记录写入数据库.
It's common to store data about all uploaded files in a database, which is easier to query for whatever properties of the file you would like to store. You can even use a Cloud Functions trigger to automatically write a record into the database for every file upload.
这篇关于列出在特定时间戳记之后在Google Cloud Storage Bucket中更改的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!