谷歌云CDN存储 gsutil 安装及使用

前言: 谷歌CDN资源文件上传我们一般通过gsutil这个工具,参考文档: https://cloud.google.com/storage/docs/gsutil/commands/config

 

一、安装python2.7

 

二、gsutil安装

[root@techroad ~]# wget http://commondatastorage.googleapis.com/pub/gsutil.tar.gz

[root@techroad ~]# tar zxvf gsutil.tar.gz

##解压之后将gsutil合作加入环境变量

[root@ ~ google-cloud-sdk]# gsutil ls

会提示权限相关需要认证

 

三、配置权限认证

[root@ ~ ~]# gsutil config -e

Backing up existing config file "/root/.boto" to "/root/.boto.bak"...

This command will create a boto config file at /root/.boto containing

your credentials, based on your responses to the following questions.

What is the full path to your private key file? /etc/gcs/dctm_account.json

##合作方提供到的json文件

Please navigate your browser to https://cloud.google.com/console#/project,

then find the project you will use, and copy the Project ID string from the

second column. Older projects do not have Project ID strings. For such projects,

click the project and then copy the Project Number listed under that project.

 

What is your project-id? p19-25309

##项目ID(json文件中有

Boto config file "/root/.boto" created. If you need to use a proxy to

access the Internet please see the instructions in that file.

 

四、测试上传

[root ~ google-cloud-sdk]# gsutil cp ./a gs://thientie/a ##存储分区

Copying file://./a [Content-Type=application/octet-stream]...

/ [1 files][ 0.0 B/ 0.0 B]

Operation completed over 1 objects.

五、上传公开链接参数

gsutil -h Cache-Control:private cp -a public-read

 

你可能感兴趣的:(linux服务器)