使用gcsfuse将数据读/写到Cloud Storage Bucket /从Cloud Storage Bucket写入数据

问题描述

要将Google Cloud Storage Bucket挂载到本地计算机上的目录中以进行处理。 使用manjaro环境并手动安装gcsfuse。

在gs:// bucket01中,有包含jpg和json文件的目录

go get -u github.com/googlecloudplatform/gcsfuse
$GOPATH/src/github.com/googlecloudplatform/gcsfuse

GOOGLE_APPLICATION_CREDENTIALS=/run/media/manjaro/gcp/key.json gcsfuse bucket01 /run/media/manjaro/gcp/bucket01

Using mount point: /run/media/manjaro/gcp/bucket01
opening GCS connection...
Mounting file system...
File system has been successfully mounted.

cd /run/media/manjaro/gcp/bucket01
ls

# empty
# The expected outcome is data from gs://bucket01 populates /run/media/manjaro/gcp/bucket01
# Updates in /run/media/manjaro/gcp/bucket01 will also be seen in gs://bucket01

我正确使用gcsfuse吗?

解决方法

请尝试使用Implicit directories

如上所述,默认情况下,不为隐式 目录的存在。由于通常的文件系统操作如 如果您设置了存储桶的结构,则mkdir会做正确的事 仅使用gcsfuse,您将不会注意到任何奇怪的地方。 但是,如果您使用其他工具在GCS中设置对象(例如 Google Developers Console中的存储浏览器),您可能会注意到 在创建引导目录之前,并非所有对象都是可见的 为他们。

gcsfuse支持名为-implicit-dirs 的标志,该标志可更改 行为