From fbbf5a4016656a4f7ddeec057a251fb52b6f1ce2 Mon Sep 17 00:00:00 2001 From: lihsai0 Date: Tue, 12 Dec 2023 15:45:00 +0800 Subject: [PATCH] fix type of PutPolicy properties not matching the server --- src/Qiniu/Storage/PutPolicy.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Qiniu/Storage/PutPolicy.cs b/src/Qiniu/Storage/PutPolicy.cs index ebfb2a4..a4a96bc 100644 --- a/src/Qiniu/Storage/PutPolicy.cs +++ b/src/Qiniu/Storage/PutPolicy.cs @@ -24,7 +24,7 @@ public class PutPolicy /// [必需]上传策略失效时刻,请使用SetExpire来设置它 /// [JsonProperty("deadline")] - public int Deadline { get; private set; } + public uint Deadline { get; private set; } /// /// [可选]"仅新增"模式 @@ -115,13 +115,13 @@ public class PutPolicy /// [可选]上传文件大小限制:最小值,单位Byte /// [JsonProperty("fsizeMin", NullValueHandling = NullValueHandling.Ignore)] - public int? FsizeMin { get; set; } + public long? FsizeMin { get; set; } /// /// [可选]上传文件大小限制:最大值,单位Byte /// [JsonProperty("fsizeLimit", NullValueHandling = NullValueHandling.Ignore)] - public int? FsizeLimit { get; set; } + public long? FsizeLimit { get; set; } /// /// [可选]上传时是否自动检测MIME @@ -153,7 +153,19 @@ public class PutPolicy /// public void SetExpires(int expireInSeconds) { - this.Deadline = (int)Util.UnixTimestamp.GetUnixTimestamp(expireInSeconds); + long unixTimestamp = Util.UnixTimestamp.GetUnixTimestamp(expireInSeconds); + if (unixTimestamp < 0) + { + this.Deadline = 0; + } + else if (unixTimestamp > uint.MaxValue) + { + this.Deadline = uint.MaxValue; + } + else + { + this.Deadline = (uint)unixTimestamp; + } } ///