[英]How can I parse the expiration date from a Windows Azure SAS key as a client?
I'm trying to check on the expiration date of the SAS key on the client side so that I can request a new SAS key once it expires. 我正在尝试在客户端检查SAS密钥的到期日期,以便我可以在过期后请求新的SAS密钥。 I'm using the Microsoft.WindowsAzure.Storage
namespace (which is version 2.0 of the azure storage library). 我正在使用Microsoft.WindowsAzure.Storage
命名空间(Azure存储库的2.0版)。 Is there a built in method for this or will I have to parse it manually? 是否有内置的方法或者我必须手动解析它?
I don't believe there's anything specific in the storage client library. 我不认为存储客户端库中有任何特定的内容。 You should be able to parse the querystring on the URI and look at the UTC date in signedexpiry
. 您应该能够解析URI上的querystring并在signedexpiry
查看UTC日期。 You can parse the querystring with HttpUtility.ParseQueryString()
. 您可以使用HttpUtility.ParseQueryString()
解析查询字符串。
Here are two caveats to think about: 这里有两个注意事项:
signedexpiry
will be part of the querystring. 如果服务器使用共享访问策略 (允许以编程方式修改/撤消访问权限),则不能保证signedexpiry
将成为查询字符串的一部分。 More on shared access policies here . 有关共享访问策略的更多信息,请点击此处 。 David's answer is correct for the question about how to parse the expiry time (+1). 对于有关如何解析到期时间(+1)的问题,David的答案是正确的。 But ultimately you should not be doing this. 但是最终您不应该这样做。 There are two better options: 有两个更好的选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.