diff --git a/.travis.yml b/.travis.yml index 46322283..8b77aa92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,10 @@ install: - sudo apt-get update && sudo apt-get install nunit mono-gmcs cli-common-dev libgl1-mesa-dev libsdl1.2-dev libopenal-dev before_script: - - export QINIU_ACCESS_KEY="iN7NgwM31j4-BZacMjPrOQBs34UG1maYCAQmhdCV" - - export QINIU_SECRET_KEY="6QTOr2Jg1gcZEWDQXKOGZh5PziC2MCV5KsntT70j" - - export QINIU_TEST_BUCKET="qtestbucket" - - export QINIU_TEST_DOMAIN="qiniuphotos.qiniudn.com" + - export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm + - export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz + - export QINIU_TEST_BUCKET="csharpsdk" + - export QINIU_TEST_DOMAIN="csharpsdk.qiniudn.com" script: - make diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f278107..7cfc476c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ ## CHANGE LOG +### v6.1.4 +2014-07-24 [#55](https://github.com/qiniu/csharp-sdk/pull/55) +- [#54] 调整上传user agent,更新put policy + +### v6.1.3 +2014-07-10 [#53](https://github.com/qiniu/csharp-sdk/pull/53) +- [#52] 调整上传host + ### v6.1.2 2014-05-30 [#51](https://github.com/qiniu/csharp-sdk/pull/51) - [#46] nuget 安装文档 diff --git a/Qiniu.Test/Auth/PutPolicy.cs b/Qiniu.Test/Auth/PutPolicy.cs index 3ea4222f..06b79c8a 100644 --- a/Qiniu.Test/Auth/PutPolicy.cs +++ b/Qiniu.Test/Auth/PutPolicy.cs @@ -22,7 +22,7 @@ public class GetPolicyTest:QiniuTestBase public void MakeRequestTest() { string actual; - FileOpUrl = "http://icattlecoder-private.qiniudn.com/img.jpg?download/avialkjdf" + StringEx.ToUrlEncode("橛苛要工苛") ; + FileOpUrl = "http://private-res.qiniudn.com/gogopher.jpg??download/avialkjdf" + StringEx.ToUrlEncode("橛苛要工苛") ; actual = GetPolicy.MakeRequest(FileOpUrl); //System.Diagnostics.Process.Start(actual); diff --git a/Qiniu.Test/IO/IOClientTest.cs b/Qiniu.Test/IO/IOClientTest.cs index decd1a06..03c44ab5 100644 --- a/Qiniu.Test/IO/IOClientTest.cs +++ b/Qiniu.Test/IO/IOClientTest.cs @@ -40,7 +40,6 @@ public void PutPolicyTest(){ policy = new PutPolicy("bucket"); - policy.AsyncOps=""; policy.CallBackBody="uid=123"; policy.CallBackUrl="www.qiniu.com"; policy.DetectMime = 1; @@ -50,11 +49,11 @@ public void PutPolicyTest(){ policy.PersistentOps = "avthumb/m3u8/preset/video_16x9_440k"; try { string result = policy.ToString(); - string expect = "{\"scope\":\"bucket\",\"callBackUrl\":\"www.qiniu.com\",\"callBackBody\":\"uid=123\",\"asyncOps\":\"\",\"deadline\":0,\"insertOnly\":1,\"detectMime\":1,\"fsizeLimit\":4096,\"persistentNotifyUrl\":\"www.yourdomain.com/persistentNotifyUrl\",\"persistentOps\":\"avthumb/m3u8/preset/video_16x9_440k\"}"; + string expect = "{\"scope\":\"bucket\",\"callBackUrl\":\"www.qiniu.com\",\"callBackBody\":\"uid=123\",\"deadline\":0,\"insertOnly\":1,\"detectMime\":1,\"fsizeLimit\":4096,\"persistentNotifyUrl\":\"www.yourdomain.com/persistentNotifyUrl\",\"persistentOps\":\"avthumb/m3u8/preset/video_16x9_440k\"}"; Assert.IsTrue(result==expect,"PutPolicyTest Failure"); } catch (Exception ee){ Assert.IsTrue (false, "PutPolicyTest Failure"); - } + } } @@ -65,7 +64,7 @@ public void PutPolicyTest(){ public void PutFileTest() { - IOClient target = new IOClient(); + IOClient target = new IOClient(); string key = NewKey; PrintLn (key); PutExtra extra = new PutExtra (); // TODO: 初始化为适当的值 @@ -96,7 +95,7 @@ public void PutFileTest() public void PutFileWithoutKeyTest() { - IOClient target = new IOClient(); + IOClient target = new IOClient(); string key = NewKey; PrintLn (key); PutExtra extra = new PutExtra (); // TODO: 初始化为适当的值 @@ -119,31 +118,31 @@ public void PutFileWithoutKeyTest() //target.PutFile("error", "error", "error", null); Assert.IsTrue (ret.OK, "PutFileTest Failure"); - } - [Test] - public void PutTest() - { - IOClient target = new IOClient(); - string key = NewKey; - PrintLn(key); - PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值 - extra.MimeType = "text/plain"; - extra.Crc32 = 123; - extra.CheckCrc = CheckCrcType.CHECK; - extra.Params = new System.Collections.Generic.Dictionary(); - PutPolicy put = new PutPolicy(Bucket); - target.PutFinished += new EventHandler((o, e) => - { - if (e.OK) - { - RSHelper.RSDel(Bucket, key); - } - }); - string token = put.Token(); - PutRet ret = target.Put(put.Token(), key, StreamEx.ToStream("Hello, Qiniu Cloud!"), extra); - - Assert.IsTrue(ret.OK, "PutFileTest Failure"); - + } + [Test] + public void PutTest() + { + IOClient target = new IOClient(); + string key = NewKey; + PrintLn(key); + PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值 + extra.MimeType = "text/plain"; + extra.Crc32 = 123; + extra.CheckCrc = CheckCrcType.CHECK; + extra.Params = new System.Collections.Generic.Dictionary(); + PutPolicy put = new PutPolicy(Bucket); + target.PutFinished += new EventHandler((o, e) => + { + if (e.OK) + { + RSHelper.RSDel(Bucket, key); + } + }); + string token = put.Token(); + PutRet ret = target.Put(put.Token(), key, StreamEx.ToStream("Hello, Qiniu Cloud!"), extra); + + Assert.IsTrue(ret.OK, "PutFileTest Failure"); + } [Test] public void PutWithoutKeyTest() diff --git a/Qiniu/Conf/Config.cs b/Qiniu/Conf/Config.cs index 978b94d8..e5892c81 100644 --- a/Qiniu/Conf/Config.cs +++ b/Qiniu/Conf/Config.cs @@ -5,7 +5,9 @@ namespace Qiniu.Conf { public class Config { - public static string USER_AGENT = "qiniu csharp-sdk v6.0.0"; + public static string VERSION = "6.1.4"; + + public static string USER_AGENT = getUa(); #region 帐户信息 /// /// 七牛提供的公钥,用于识别用户 @@ -52,5 +54,9 @@ public static void Init() RSF_HOST = System.Configuration.ConfigurationManager.AppSettings["RSF_HOST"]; PREFETCH_HOST = System.Configuration.ConfigurationManager.AppSettings["PREFETCH_HOST"]; } + private static string getUa() + { + return "QiniuCsharp/"+ VERSION + " (" + Environment.OSVersion.Version.ToString() + "; )"; + } } } diff --git a/Qiniu/RS/PutPolicy.cs b/Qiniu/RS/PutPolicy.cs index be74d914..e9899d84 100644 --- a/Qiniu/RS/PutPolicy.cs +++ b/Qiniu/RS/PutPolicy.cs @@ -17,7 +17,6 @@ public class PutPolicy private string callBackBody; private string returnUrl; private string returnBody; - private string asyncOps; private string saveKey; private int insertOnly; private int detectMime; @@ -25,6 +24,7 @@ public class PutPolicy private long fsizeLimit; private string persistentOps; private string persistentNotifyUrl; + private string persistentPipeline; private string endUser; private UInt64 expires = 3600; private UInt64 deadline = 0; @@ -67,22 +67,13 @@ public string ReturnUrl { /// /// 文件上传成功后,自定义从 Qiniu-Cloud-Server 最终返回給终端 App-Client 的数据。支持 魔法变量,不可与 callbackBody 同时使用。 - /// + /// [JsonProperty("returnBody")] public string ReturnBody { get { return returnBody; } set { returnBody = value; } } - /// - /// 指定文件(图片/音频/视频)上传成功后异步地执行指定的预转操作。每个预转指令是一个API规格字符串,多个预转指令可以使用分号“;”隔开 - /// - [JsonProperty("asyncOps")] - public string AsyncOps { - get { return asyncOps; } - set { asyncOps = value; } - } - /// /// 给上传的文件添加唯一属主标识,特殊场景下非常有用,比如根据终端用户标识给图片或视频打水印 /// @@ -110,7 +101,7 @@ public string SaveKey { return saveKey; } set{ - saveKey = value; + saveKey = value; } } @@ -123,7 +114,7 @@ public int InsertOnly { get { return insertOnly; } - set{ + set{ insertOnly = value; } } @@ -138,7 +129,7 @@ public int DetectMime { return detectMime; } set{ - detectMime = value; + detectMime = value; } } @@ -172,7 +163,7 @@ public long FsizeLimit { get { return fsizeLimit; } - set{ + set{ fsizeLimit = value; } } @@ -187,7 +178,7 @@ public string PersistentNotifyUrl { } /// - /// 可指定音视频文件上传完成后,需要进行的转码持久化操作。asyncOps的处理结果保存在缓存当中,有可能失效。而persistentOps的处理结果以文件形式保存在bucket中,体验更佳。[数据处理(持久化)](http://docs.qiniu.com/api/persistent-ops.html + /// 可指定音视频文件上传完成后,需要进行的转码持久化操作。persistentOps的处理结果以文件形式保存在bucket中,体验更佳。[数据处理(持久化)](http://docs.qiniu.com/api/persistent-ops.html /// [JsonProperty("persistentOps")] public string PersistentOps { @@ -195,6 +186,15 @@ public string PersistentOps { set { persistentOps = value; } } + // + /// 可指定音视频文件上传后处理的队列,不指定时在公共队列中。persistentOps的处理结果以文件形式保存在bucket中,体验更佳。[数据处理(持久化)](http://docs.qiniu.com/api/persistent-ops.html + /// + [JsonProperty("persistentPipeline")] + public string PersistentPipeline { + get { return persistentPipeline; } + set { persistentPipeline = value; } + } + /// /// Initializes a new instance of the class. /// @@ -217,7 +217,7 @@ public string Token (Mac mac=null) } if (string.IsNullOrEmpty (callBackUrl) ^ string.IsNullOrEmpty (callBackBody)) { throw new Exception ("CallBackUrl and CallBackBody error"); - } + } if (!string.IsNullOrEmpty (returnUrl) && !string.IsNullOrEmpty (callBackUrl)) { throw new Exception ("returnUrl and callBackUrl error"); } @@ -225,7 +225,7 @@ public string Token (Mac mac=null) mac = new Mac (Config.ACCESS_KEY, Config.Encoding.GetBytes (Config.SECRET_KEY)); } this.deadline = (UInt32)((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 + (long)expires); - string flag = this.ToString (); + string flag = this.ToString (); return mac.SignWithData (Config.Encoding.GetBytes (flag)); }