简体   繁体   中英

Azure Blob sharing SAS time window

I trying to share blob for one minute with this code:

    public static void CdnInit()
    {
        StorageAccount = CloudStorageAccount.Parse(ConnectionString);
        BlobClient = StorageAccount.CreateCloudBlobClient();
    }

    public static string GetSharedBlobUrl(ContainerType conteiner, string fileName)
    {
        CloudBlob blob = BlobClient.GetBlobReference(containerNameByType(conteiner) + @"/" + fileName);
        return StorageUrl + "/" + containerNameByType(conteiner) + "/" + fileName + blob.GetSharedAccessSignature(new SharedAccessPolicy()
        {
            Permissions = SharedAccessPermissions.Read,
            SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromMinutes(1)
        });

    }

But redirecting to generated url giving me this error:

Access without signed identifier cannot have time window more than 1 hour

I tried many time combinations but the same result.

Try using DateTime.Now instead of DateTime.UtcNow, thats the problem. UtcNow gives date according to GMT and that could be more than 1 hour time as per your local time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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