Google Cloud Storage忽略定界符 [英] Google Cloud Storage ignoring delimiter

查看:59
本文介绍了Google Cloud Storage忽略定界符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Google云存储中检索JSON文件.JSON文件与相应的音频文件存储在同一文件夹中,如下所示:

I am trying to retrive JSON files from google cloud storage. The JSON files are stored in the same folder as their corresponding audio files, as follows:

bucket
  folder1
    audio.wav
    audio.json
  folder2
    audio.wav
    audio.json

我正在使用nodejs,并按以下方式调用云存储:

I'm using nodejs, and calling cloud storage as follows:

bucket.getFiles({
    delimeter: 'audio' //should be preventing loading of audio files but it isnt
  }).then((data) => {
    console.log(data)
  }).catch((error) => {
    console.log(error)
  })

我觉得这可能与Google处理文件夹的方式有关,但我不确定.首先是文件的存储方式:

I have a feeling it might be related to how Google handles folders, but I'm not really sure. Here is how the files are being stored in the first place:

const storage = require('@google-cloud/storage')();

  const filename = `recordings/${path.parse(req.body.RecordingUrl).name}/audio.wav`;
  const file = storage
    .bucket(config.RESULTS_BUCKET)
    .file(filename)

这将导致某种形式的字符串,该字符串为音频文件分配唯一的ID作为文件夹名称,然后附加/audio.wav ,并且云存储以某种方式将其识别为文件夹.只是一个猜测,但不确定是否可以解决.有人知道我可能在做错什么吗?

Which results in some sort of string that assigns the audio file a unique ID as the folder name, and then appends the /audio.wav, and somehow cloud storage recognizes that as a folder. Just a guess, but not sure how to solve that if it's the case. Anyone know what I might be doing wrong?

推荐答案

如果您试图列出所有以 .json 结尾的对象,那么您不想在以下位置设置定界符全部.定界符用于分层列表.您几乎永远都不想将其设置为unset和/以外的任何值.请参见列表文档.

If you're trying to list all objects that end in .json, then you don't want to set a delimiter at all. The delimiter is used for hierarchical listing. You almost never want to set it to any values other than unset and /. See list documentation.

这篇关于Google Cloud Storage忽略定界符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆