diff --git a/Backup2Cloud/Backup2Cloud.csproj b/Backup2Cloud/Backup2Cloud.csproj
index 1feb291..368ad75 100644
--- a/Backup2Cloud/Backup2Cloud.csproj
+++ b/Backup2Cloud/Backup2Cloud.csproj
@@ -5,9 +5,9 @@
netcoreapp2.0
false
- 0.0.6.1
- 0.0.6.1
- 0.0.6.1
+ 0.0.7.0
+ 0.0.7.0
+ 0.0.7
sanjusss
定时将服务器上的文件备份到云存储。
@@ -22,6 +22,7 @@
+
diff --git a/Backup2Cloud/Worker/Uploader/GoogleCloudStorageUploader.cs b/Backup2Cloud/Worker/Uploader/GoogleCloudStorageUploader.cs
new file mode 100644
index 0000000..13f4022
--- /dev/null
+++ b/Backup2Cloud/Worker/Uploader/GoogleCloudStorageUploader.cs
@@ -0,0 +1,74 @@
+using Google.Apis.Auth.OAuth2;
+using Google.Cloud.Storage.V1;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Backup2Cloud.Worker.Uploader
+{
+ ///
+ /// 谷歌云存储上传实现类
+ ///
+ [ProviderName("google")]
+ public class GoogleCloudStorageUploader : IUploader
+ {
+ ///
+ /// 服务账号密钥文件位置
+ ///
+ public string jsonKeyFile;
+ ///
+ /// 存储空间名
+ ///
+ public string bucket;
+ ///
+ /// 文件在Bucket下的路径,作为上传路径前缀。
+ ///
+ public string path;
+ ///
+ /// 提示信息
+ ///
+ public string Tips
+ {
+ get
+ {
+ return "jsonKeyFile:服务账号密钥文件位置" +
+ "bucket:存储空间名;" +
+ "path:文件在Bucket/桶下的路径前缀,例如\"data/some\",最终会生成类似\"data/some201809092054.zip\"之类的文件";
+ }
+ }
+
+ ///
+ /// 获取示例实例。
+ ///
+ /// 示例配置实例
+ public IUploader GetExample()
+ {
+ return new GoogleCloudStorageUploader()
+ {
+ jsonKeyFile = "/conf/xxx.json",
+ bucket = "backup",
+ path = "data/some"
+ };
+ }
+
+ ///
+ /// 上传指定文件。
+ ///
+ /// 待上传的文件
+ /// 文件在云空间里的后缀
+ ///
+ public Task Upload(string file, string suffix)
+ {
+ using (FileStream stream = new FileStream(file, FileMode.Open))
+ {
+ GoogleCredential credential = GoogleCredential.FromFile(jsonKeyFile);
+ var client = StorageClient.Create(credential);
+ client.UploadObject(bucket, path + suffix, "application/x-zip-compressed", stream);
+ }
+
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/README.md b/README.md
index 515ed29..80d9cc8 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@
|[青云](https://www.qingcloud.com)|[对象存储](https://www.qingcloud.com/products/qingstor/)|![支持](https://img.shields.io/badge/support-Yes-green.svg)|
|[金山云](https://www.ksyun.com)|[对象存储](https://www.ksyun.com/post/product/KS3)|![不支持](https://img.shields.io/badge/support-No-red.svg)|仅限企业用户|
|[Azure](https://www.azure.cn/zh-cn/)|[Blob 存储](https://www.azure.cn/zh-cn/home/features/storage/blobs/)|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)|
-|[Google Cloud](https://cloud.google.com)|[Google Cloud Storage](https://cloud.google.com/storage/)|![即将到来](https://img.shields.io/badge/support-Future-yellow.svg)|
+|[Google Cloud](https://cloud.google.com)|[Google Cloud Storage](https://cloud.google.com/storage/)|![支持](https://img.shields.io/badge/support-Yes-green.svg)|
# 支持的数据源
diff --git a/appveyor.yml b/appveyor.yml
index 87494d4..66f1e1e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,5 +1,5 @@
-version: 0.0.6.1.{build}
+version: 0.0.7.0.{build}
image: Visual Studio 2017
shallow_clone: true
build_script:
diff --git a/example.json b/example.json
index 6aacc70..4b94a3f 100644
--- a/example.json
+++ b/example.json
@@ -58,6 +58,23 @@
},
"Tips": "name:任务名称;provider:上传服务提供商;path:需要备份的文件夹或文件在本地的路径;crontab:启动备份的时间集合,可以参考http://cron.qqe2.com/,使用时需要注意时区;command:打包备份文件夹或文件之前额外执行的命令,例如备份数据库等,使用docker容器时须注意执行环境,可以为空;commandArgs:打包备份文件夹或文件之前额外执行的命令的参数,,可以为空;uploader:上传设置"
},
+ {
+ "name": "上传到 google",
+ "provider": "google",
+ "path": "/data",
+ "crontab": [
+ "0,30 * * * * ?"
+ ],
+ "command": "echo",
+ "commandArgs": "Hello World!",
+ "uploader": {
+ "jsonKeyFile": "/conf/xxx.json",
+ "bucket": "backup",
+ "path": "data/some",
+ "Tips": "jsonKeyFile:服务账号密钥文件位置bucket:存储空间名;path:文件在Bucket/桶下的路径前缀,例如\"data/some\",最终会生成类似\"data/some201809092054.zip\"之类的文件"
+ },
+ "Tips": "name:任务名称;provider:上传服务提供商;path:需要备份的文件夹或文件在本地的路径;crontab:启动备份的时间集合,可以参考http://cron.qqe2.com/,使用时需要注意时区;command:打包备份文件夹或文件之前额外执行的命令,例如备份数据库等,使用docker容器时须注意执行环境,可以为空;commandArgs:打包备份文件夹或文件之前额外执行的命令的参数,,可以为空;uploader:上传设置"
+ },
{
"name": "上传到 huawei",
"provider": "huawei",