Skip to content

Commit

Permalink
fix type of PutPolicy properties not matching the server
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Dec 12, 2023
1 parent 2e55079 commit fbbf5a4
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Qiniu/Storage/PutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class PutPolicy
/// [必需]上传策略失效时刻,请使用SetExpire来设置它
/// </summary>
[JsonProperty("deadline")]
public int Deadline { get; private set; }
public uint Deadline { get; private set; }

/// <summary>
/// [可选]"仅新增"模式
Expand Down Expand Up @@ -115,13 +115,13 @@ public class PutPolicy
/// [可选]上传文件大小限制:最小值,单位Byte
/// </summary>
[JsonProperty("fsizeMin", NullValueHandling = NullValueHandling.Ignore)]
public int? FsizeMin { get; set; }
public long? FsizeMin { get; set; }

/// <summary>
/// [可选]上传文件大小限制:最大值,单位Byte
/// </summary>
[JsonProperty("fsizeLimit", NullValueHandling = NullValueHandling.Ignore)]
public int? FsizeLimit { get; set; }
public long? FsizeLimit { get; set; }

/// <summary>
/// [可选]上传时是否自动检测MIME
Expand Down Expand Up @@ -153,7 +153,19 @@ public class PutPolicy
/// <param name="expireInSeconds"></param>
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;
}
}

/// <summary>
Expand Down

0 comments on commit fbbf5a4

Please sign in to comment.