Google cloud storage Google云存储节点和JSON API在尝试列出时不返回某些文件夹
尝试使用NodeJS客户端库(getFiles)时- ) 在这两种情况下,JSON API(objects/list-)响应似乎都不会返回某些文件夹。 当使用Google cloud storage Google云存储节点和JSON API在尝试列出时不返回某些文件夹,google-cloud-storage,google-api-nodejs-client,Google Cloud Storage,Google Api Nodejs Client,尝试使用NodeJS客户端库(getFiles)时- ) 在这两种情况下,JSON API(objects/list-)响应似乎都不会返回某些文件夹。 当使用gsutil ls时,它会按预期列出所有文件夹,并使用谷歌云控制台浏览GCS bucket,同时也会按预期列出所有文件 存储API中是否有可能导致这种情况发生的更改 更新: 列出使用NodeJS客户端SDK进行存储的GCS文件夹路径的代码: import * as functions from 'firebase-functions';
gsutil ls
时,它会按预期列出所有文件夹,并使用谷歌云控制台浏览GCS bucket,同时也会按预期列出所有文件
存储API中是否有可能导致这种情况发生的更改
更新:
列出使用NodeJS客户端SDK进行存储的GCS文件夹路径的代码:
import * as functions from 'firebase-functions';
import { Storage } from '@google-cloud/storage';
import { globVars } from '../admin/admin';
const projectId = process.env.GCLOUD_PROJECT;
// shared global variables setup
const { keyFilename } = globVars;
// Storage set up
const storage = new Storage({
projectId,
keyFilename,
});
export const gcsListPath = functions
.region('europe-west2')
.runWith({ timeoutSeconds: 540, memory: '256MB' })
.https.onCall(async (data, context) => {
if (context.auth?.token.email_verified) {
const { bucketName, prefix, pathList = false, fileList = false } = data;
let list;
const options = {
autoPaginate: false,
delimiter: '',
prefix,
};
if (pathList) {
options.delimiter = '/';
const verboseResponse = await storage
.bucket(bucketName)
.getFiles(options);
list = verboseResponse[2].prefixes;
}
if (fileList) {
const [files] = await storage
.bucket(bucketName)
.getFiles(options);
list = files.map((file) => file.name);
}
return { list };
} else {
return {
error: { message: 'Bad Request', status: 'INVALID_ARGUMENT' },
};
}
});
看起来分页功能限制了结果。实施
nextQuery
返回列表的下一页。您能分享您编写的代码吗?能够在我们的电脑上复制side@guillaumeblaquiere,谢谢你的留言。我已经用我们用来列出GCS文件夹的代码更新了这个问题。奇怪的是,当我们使用JSON_API时,我们看到了同样的问题。需要注意的是,这个问题只是最近才出现的,我们在过去3个月里一直使用API列出文件夹路径,没有出现任何问题。