繁体   English   中英

在Windows Azure Media Services中签名URL

[英]Signing url's in Windows Azure Media Services

我试图在Windows Azure媒体服务中找到与以下S3功能等效的功能: http : //www.bucketexplorer.com/documentation/amazon-s3--how-to-generate-url-for-amazon-s3- file.html#signedurl

我听说可以通过S3和CDN(例如Akamai)来实现这样的签名URL。

2个问题。

1)是否有人对如何在WAMS中实现签名URL提出建议?

2)有人知道Azure将与Akamai等其他CDN挂钩的程度吗?

提前致谢。

Windows Azure中此功能的等效功能称为共享访问签名 Media Services确实支持创建SAS Origin Locator

您可以阅读有关如何使用.NET SDK创建SAS Locator的官方文档。

或者您可以检查我在GitHub上的项目 ,尤其是Locators实施

用于为特定资产生成SAS定位器的代码示例如下:

public string GetSasLocator(IAsset asset)
{
    // Create an 1-day readonly access policy. 
    IAccessPolicy streamingPolicy = this.MediaService.MediaContext.AccessPolicies.Create("Full Access Policy",
        TimeSpan.FromMinutes(20),
        AccessPermissions.List | AccessPermissions.Read | AccessPermissions.Read);

    // Create the origin locator. Set the start time as 5 minutes 
    // before the present so that the locator can be accessed immediately 
    // if there is clock skew between the client and server.
    ILocator sasLocator =
        (from l in this.MediaService.MediaContext.Locators
         where l.Type == LocatorType.Sas && l.AssetId.Equals(asset.Id)
         select l).FirstOrDefault();

    if (sasLocator != null && sasLocator.ExpirationDateTime < DateTime.UtcNow)
    {
        sasLocator.Delete();
        sasLocator = null;
    }

    if (sasLocator == null)
    {
        sasLocator = this.MediaService.MediaContext
            .Locators.CreateSasLocator(asset,
         streamingPolicy,
         DateTime.UtcNow.AddMinutes(-5));
    }
    // Create a full URL to the manifest file. Use this for playback
    // in streaming media clients. 
    string sasUrl = sasLocator.Path;

    // Display the full URL to the streaming manifest file.
    Console.WriteLine("URL to for blob upload: ");
    Console.WriteLine(sasUrl);

    return sasUrl;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM