本文整理汇总了C#中IDataStore.GetPreSignedUri方法的典型用法代码示例。如果您正苦于以下问题:C# IDataStore.GetPreSignedUri方法的具体用法?C# IDataStore.GetPreSignedUri怎么用?C# IDataStore.GetPreSignedUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataStore
的用法示例。
在下文中一共展示了IDataStore.GetPreSignedUri方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPreSignedUri
public static string GetPreSignedUri(int file_id, int id_tenant, string id_user, string stream, int file_number,
string file_name, IDataStore data_store)
{
var attachment_path = GetFileKey(id_user, stream, file_number, file_name);
if (data_store == null)
data_store = MailBoxManager.GetDataStore(id_tenant);
string url;
if (data_store is S3Storage)
{
var content_disposition_file_name = ContentDispositionUtil.GetHeaderValue(file_name);
var headers_for_url = new []{"Content-Disposition:" + content_disposition_file_name};
url = data_store.GetPreSignedUri("", attachment_path, TimeSpan.FromMinutes(5), headers_for_url).ToString();
}
else
{
//TODO: Move url to config;
attachment_path = "/addons/mail/httphandlers/download.ashx";
var uri_builder = new UriBuilder(CommonLinkUtility.GetFullAbsolutePath(attachment_path));
if (uri_builder.Uri.IsLoopback)
{
uri_builder.Host = Dns.GetHostName();
}
var query = uri_builder.Query;
query += "attachid=" + file_id + "&";
query += "stream=" + stream + "&";
query += CommonLinkUtility.AuthKey + "=" + EmailValidationKeyProvider.GetEmailKey(file_id + stream);
url = uri_builder.Uri + "?" + query;
}
return url;
}