Skip to content

Commit

Permalink
Merge pull request #55 from qiniu/develop
Browse files Browse the repository at this point in the history
Release 6.1.4
  • Loading branch information
longbai committed Jul 24, 2014
2 parents 88d7bee + 4234beb commit d1cfc54
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 54 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 安装文档
Expand Down
2 changes: 1 addition & 1 deletion Qiniu.Test/Auth/PutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
59 changes: 29 additions & 30 deletions Qiniu.Test/IO/IOClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
}

}

Expand All @@ -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: 初始化为适当的值
Expand Down Expand Up @@ -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: 初始化为适当的值
Expand All @@ -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<string, string>();
PutPolicy put = new PutPolicy(Bucket);
target.PutFinished += new EventHandler<PutRet>((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<string, string>();
PutPolicy put = new PutPolicy(Bucket);
target.PutFinished += new EventHandler<PutRet>((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()
Expand Down
8 changes: 7 additions & 1 deletion Qiniu/Conf/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 帐户信息
/// <summary>
/// 七牛提供的公钥,用于识别用户
Expand Down Expand Up @@ -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() + "; )";
}
}
}
36 changes: 18 additions & 18 deletions Qiniu/RS/PutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class PutPolicy
private string callBackBody;
private string returnUrl;
private string returnBody;
private string asyncOps;
private string saveKey;
private int insertOnly;
private int detectMime;
private string mimeLimit;
private long fsizeLimit;
private string persistentOps;
private string persistentNotifyUrl;
private string persistentPipeline;
private string endUser;
private UInt64 expires = 3600;
private UInt64 deadline = 0;
Expand Down Expand Up @@ -67,22 +67,13 @@ public string ReturnUrl {

/// <summary>
/// 文件上传成功后,自定义从 Qiniu-Cloud-Server 最终返回給终端 App-Client 的数据。支持 魔法变量,不可与 callbackBody 同时使用。
/// </summary>
/// </summary>
[JsonProperty("returnBody")]
public string ReturnBody {
get { return returnBody; }
set { returnBody = value; }
}

/// <summary>
/// 指定文件(图片/音频/视频)上传成功后异步地执行指定的预转操作。每个预转指令是一个API规格字符串,多个预转指令可以使用分号“;”隔开
/// </summary>
[JsonProperty("asyncOps")]
public string AsyncOps {
get { return asyncOps; }
set { asyncOps = value; }
}

/// <summary>
/// 给上传的文件添加唯一属主标识,特殊场景下非常有用,比如根据终端用户标识给图片或视频打水印
/// </summary>
Expand Down Expand Up @@ -110,7 +101,7 @@ public string SaveKey {
return saveKey;
}
set{
saveKey = value;
saveKey = value;
}
}

Expand All @@ -123,7 +114,7 @@ public int InsertOnly {
get {
return insertOnly;
}
set{
set{
insertOnly = value;
}
}
Expand All @@ -138,7 +129,7 @@ public int DetectMime {
return detectMime;
}
set{
detectMime = value;
detectMime = value;
}
}

Expand Down Expand Up @@ -172,7 +163,7 @@ public long FsizeLimit {
get {
return fsizeLimit;
}
set{
set{
fsizeLimit = value;
}
}
Expand All @@ -187,14 +178,23 @@ public string PersistentNotifyUrl {
}

/// <summary>
/// 可指定音视频文件上传完成后,需要进行的转码持久化操作。asyncOps的处理结果保存在缓存当中,有可能失效。而persistentOps的处理结果以文件形式保存在bucket中,体验更佳。[数据处理(持久化)](http://docs.qiniu.com/api/persistent-ops.html
/// 可指定音视频文件上传完成后,需要进行的转码持久化操作。persistentOps的处理结果以文件形式保存在bucket中,体验更佳。[数据处理(持久化)](http://docs.qiniu.com/api/persistent-ops.html
/// </summary>
[JsonProperty("persistentOps")]
public string PersistentOps {
get { return persistentOps; }
set { persistentOps = value; }
}

// <summary>
/// 可指定音视频文件上传后处理的队列,不指定时在公共队列中。persistentOps的处理结果以文件形式保存在bucket中,体验更佳。[数据处理(持久化)](http://docs.qiniu.com/api/persistent-ops.html
/// </summary>
[JsonProperty("persistentPipeline")]
public string PersistentPipeline {
get { return persistentPipeline; }
set { persistentPipeline = value; }
}

/// <summary>
/// Initializes a new instance of the <see cref="Qiniu.RS.PutPolicy"/> class.
/// </summary>
Expand All @@ -217,15 +217,15 @@ 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");
}
if (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));
}

Expand Down

0 comments on commit d1cfc54

Please sign in to comment.