Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Implemented caching for sas response if a validity period is provided… #2039

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

szilardd
Copy link

@szilardd szilardd commented Aug 3, 2018

Brief description of the changes

Currenly when using the Azure version and activating the 'chunked' option, on every chunk it calls the signature endpoint to retrieve a SAS.

But you can specify an expiry time for the SAS (SharedAccessBlobPolicy.SharedAccessExpiryTime) and based on this, the SAS can be cached by the browser and a new request can be sent only when it expires

For reference this is the C# code that creates the SAS and returns the url and the validity period

// the SAS will be valid for 5 minutes
var validForMinutes = 5;
var blob = new CloudBlockBlob(new Uri(blobUri), credentials);

var policy = new SharedAccessBlobPolicy()
{
    Permissions = SharedAccessBlobPermissions.Write,
    SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(validForMinutes),
};

var sas = blob.GetSharedAccessSignature(policy);

// instead of just returing the SAS url, return also the amount of time the SAS is valid for
return new
{
    sasUrl = blob.Uri + sas,
    validFor = validForMinutes * 60 // seconds
};

What browsers and operating systems have you tested these changes on?

Chrome on Windows so far, but will test across other browsers

Have you written unit tests? If not, explain why.

Looking for a confirmation first that this is something that the maintainers will agree on including. Happy to write tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants