add tencentyun cos license

This commit is contained in:
wood
2020-06-28 12:17:08 +08:00
parent 603b2a3ccd
commit bcd483dd21
6 changed files with 59 additions and 35 deletions
@@ -72,10 +72,6 @@ namespace Duplicati.Library.Backend
public string Path { get; set; }
}
//static COS()
//{
//}
public COS()
{
}
@@ -85,7 +81,7 @@ namespace Duplicati.Library.Backend
_cosOptions = new CosOptions();
var uri = new Utility.Uri(url);
m_prefix = uri.HostAndPath?.Trim()?.Trim('/').Trim('/')?.Trim('\\')?.Trim('\\');
m_prefix = uri.HostAndPath?.Trim()?.Trim('/')?.Trim('\\');
if (!string.IsNullOrEmpty(m_prefix))
{
@@ -214,29 +210,28 @@ namespace Duplicati.Library.Backend
try
{
_cosXml = GetCosXml();
string bucket = _cosOptions.Bucket;
string key = GetFullKey(remotename);
string bucket = _cosOptions.Bucket; //存储桶,格式:BucketName-APPID
string key = GetFullKey(remotename); //对象在存储桶中的位置,即称对象键
//string bucket = "examplebucket-1250000000"; //存储桶,格式:BucketName-APPID
//string key = "exampleobject"; //对象在存储桶中的位置,即称对象键
DeleteObjectRequest request = new DeleteObjectRequest(bucket, key);
//设置签名有效时长
request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
//执行请求
DeleteObjectResult result = _cosXml.DeleteObject(request);
//请求成功
Console.WriteLine(result.GetResultInfo());
//result.GetResultInfo()
}
catch (COSXML.CosException.CosClientException clientEx)
{
//请求失败
Console.WriteLine("CosClientException: " + clientEx);
Logging.Log.WriteErrorMessage(LOGTAG, "Delete", clientEx, "Delete failed: {0}", remotename);
throw;
}
catch (COSXML.CosException.CosServerException serverEx)
{
//请求失败
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
Logging.Log.WriteErrorMessage(LOGTAG, "Delete", serverEx, "Delete failed: {0}, {1}", remotename, serverEx.GetInfo());
throw;
}
}
@@ -268,7 +263,7 @@ namespace Duplicati.Library.Backend
public void CreateFolder()
{
// cos no folders need to be created
}
public void Dispose()
@@ -295,18 +290,16 @@ namespace Duplicati.Library.Backend
//执行请求
PutObjectResult result = _cosXml.PutObject(request);
//对象的 eTag
string eTag = result.eTag;
//string eTag = result.eTag;
}
catch (COSXML.CosException.CosClientException clientEx)
{
//请求失败
Console.WriteLine("CosClientException: " + clientEx);
Logging.Log.WriteErrorMessage(LOGTAG, "PutAsync", clientEx, "Put failed: {0}", remotename);
throw;
}
catch (COSXML.CosException.CosServerException serverEx)
{
//请求失败
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
Logging.Log.WriteErrorMessage(LOGTAG, "PutAsync", serverEx, "Put failed: {0}, {1}", remotename, serverEx.GetInfo());
throw;
}
@@ -337,27 +330,25 @@ namespace Duplicati.Library.Backend
Utility.Utility.CopyStream(ms, stream);
//请求成功
Console.WriteLine(result.GetResultInfo());
//Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
//请求失败
Console.WriteLine("CosClientException: " + clientEx);
Logging.Log.WriteErrorMessage(LOGTAG, "Get", clientEx, "Get failed: {0}", remotename);
throw;
}
catch (COSXML.CosException.CosServerException serverEx)
{
//请求失败
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
Logging.Log.WriteErrorMessage(LOGTAG, "Get", serverEx, "Get failed: {0}, {1}", remotename, serverEx.GetInfo());
throw;
}
}
public void Rename(string oldname, string newname)
{
CosXml cosXml = GetCosXml();
try
{
CosXml cosXml = GetCosXml();
string sourceAppid = _cosOptions.Appid; //账号 appid
string sourceBucket = _cosOptions.Bucket; //"源对象所在的存储桶
string sourceRegion = _cosOptions.Region; //源对象的存储桶所在的地域
@@ -377,24 +368,21 @@ namespace Duplicati.Library.Backend
request.SetCopyMetaDataDirective(COSXML.Common.CosMetaDataDirective.COPY);
//执行请求
CopyObjectResult result = cosXml.CopyObject(request);
//请求成功
Console.WriteLine(result.GetResultInfo());
Logging.Log.WriteInformationMessage(LOGTAG, "COS rename ok", $"cos copy: {key}, " + result.GetResultInfo());
//请求成功
//Console.WriteLine(result.GetResultInfo());
// 删除
Delete(oldname);
}
catch (COSXML.CosException.CosClientException clientEx)
{
//请求失败
Console.WriteLine("CosClientException: " + clientEx);
Logging.Log.WriteErrorMessage(LOGTAG, "Rename", clientEx, "Rename failed: {0} to {1}", oldname, newname);
throw;
}
catch (COSXML.CosException.CosServerException serverEx)
{
//请求失败
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
Logging.Log.WriteErrorMessage(LOGTAG, "Rename", serverEx, "Rename failed: {0} to {1}, {2}", oldname, newname, serverEx.GetInfo());
throw;
}
}
@@ -1,5 +1,4 @@
using COSXML.Model.Bucket;
using Duplicati.Library.Localization.Short;
using Duplicati.Library.Localization.Short;
namespace Duplicati.Library.Backend.Strings
{
@@ -84,6 +84,12 @@
<Link>licenses\SQLite\License.txt</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\thirdparty\Tencentyun\download.txt">
<Link>licenses\Tencentyun\download.txt</Link>
</Content>
<Content Include="..\..\thirdparty\Tencentyun\LICENSE.txt">
<Link>licenses\Tencentyun\LICENSE.txt</Link>
</Content>
<Content Include="..\..\thirdparty\uplink.NET\Homepage.txt">
<Link>licenses\uplink.NET\Homepage.txt</Link>
</Content>
@@ -406,6 +412,9 @@
<None Include="..\..\thirdparty\FluentFTP\licensedata.json">
<Link>licenses\FluentFTP\licensedata.json</Link>
</None>
<None Include="..\..\thirdparty\Tencentyun\licensedata.json">
<Link>licenses\Tencentyun\licensedata.json</Link>
</None>
<None Include="..\..\thirdparty\uplink.NET\licensedata.json">
<Link>licenses\uplink.NET\licensedata.json</Link>
</None>
+20
View File
@@ -0,0 +1,20 @@
Copyright (c) 2018 腾讯云
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+1
View File
@@ -0,0 +1 @@
https://github.com/tencentyun/qcloud-sdk-dotnet
+7
View File
@@ -0,0 +1,7 @@
{
"name": "qcloud-sdk-dotnet",
"description": "",
"link": "https://github.com/tencentyun/qcloud-sdk-dotnet",
"license": "MIT",
"notes": ""
}