Read/Write 数据 to/from 使用 gcsfuse 的云存储桶

Read/Write data to/from Cloud Storage Bucket using gcsfuse

将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

As mentioned above, by default there is no allowance for the implicit existence of directories. Since the usual file system operations like mkdir will do the right thing, if you set up a bucket's structure using only gcsfuse then you will not notice anything odd about this. If, however, you use some other tool to set up objects in GCS (such as the storage browser in the Google Developers Console), you may notice that not all objects are visible until you create leading directories for them.

gcsfuse supports a flag called --implicit-dirs that changes the behavio