初始步骤

1、 域名

2、 google Cloud create project. the project name must match the domain name

3、cname

1
2

NAME TYPE DATA
www.example.com CNAME c.storage.googleapis.com.
Google Cloud SDK

oogle Cloud SDK 是一套工具,您可以使用这套工具来管理托管在 Google Cloud Platform 上的资源和应用。其中包括 gcloud、gsutil 和 bq 命令行工具。install

gsutil 工具

设置所有文件的权限可见

1

gsutil acl -r ch -u AllUsers:R gs://www.dreamerjonson.com/*
删除文件:

-r递归遍历所有

1

gsutil rm -r gs://www.dreamerjonson.com/.git/
上传单个文件

1

gsutil cp test.js gs://www.dreamerjonson.com
上传文件夹下所有文件

1

gsutil cp -r ./ gs://www.dreamerjonson.com
增量同步

-m多线程 -d 删除不匹配的文件 -r递归

1

gsutil -m rsync -d -r ./ gs://www.dreamerjonson.com
设置 MainPageSuffix 和 NotFoundPage

在以下示例中,MainPageSuffix 被设置为 index.html,NotFoundPage 被设置为 404.html:

1

gsutil web set -m index.html -e 404.html gs://www.example.com
更新默认上传权限

1

gsutil defacl ch -u AllUsers:R gs://www.dreamerjonson.com
参考资料

google domains help

storage托管静态页面

gsutil使用

gsutil快速入门

gsutil defacl

本文链接:https://dreamerjonson.com/2018/11/03/google-cloud-storage托管静态页面/

版权声明:本博客所有文章除特别声明外,均采用CC BY 4.0 CN协议许可协议。转载请注明出处!