Reputation: 173
When attempting to download a PDF file to a browser directly from Azure File Storage I get this error:
<Error>
<Code>ConditionHeadersNotSupported</Code>
<Message>
Condition headers are not supported. RequestId:a84ee68e- 001a-001b-4223-bff5e7000000 Time:2017-04-27T06:57:22.2002199Z
</Message>
</Error>
Edge: Blank page or blank page with frozen loading indicator.
FireFox: Second time, shows dialog to download file.
Chrome: Blank page or When PDF Documents “Open PDF files in default PDF viewer application” setting is checked, shows dialog to download file.
IE: Shows dialog to download file.
Safari: Displays PDF.
The behavior can be seen here:
https://peachstatepca.file.core.windows.net/content/newsletters/PresseApril2017.pdf?sv=2016-05-31&sr=f&sig=rkQEmY6IWXZqcgvhmm00gLQ%2FCZEq6nsH95S3aP9T72A%3D&se=2017-05-01T11:46:18Z&sp=r
Upvotes: 9
Views: 7714
Reputation: 27384
If you are using C# and the Nuget packages then you can do this programatically like so
var sas = fileRef.GetSharedAccessSignature(new SharedAccessFilePolicy()
{
Permissions = SharedAccessFilePermissions.Read,
SharedAccessExpiryTime = new DateTimeOffset(DateTime.UtcNow.AddHours(1))
},
new SharedAccessFileHeaders()
{
CacheControl = "no-cache, no-store, must-revalidate"
});
Upvotes: 2
Reputation: 1216
Azure File storage doesn't support Conditional Headers at this time.
A workaround is to use the CacheControl
property and set it to no-cache, no-store, must-revalidate
.
Upvotes: 2
Reputation: 1178
We were also facing this issue and the easiest way, till Azure File Team implements the suggestion given in the Azure Feedback forum, a workaround is to append extra parameter at the end of URL. So, for the above URL -- https://peachstatepca.file.core.windows.net/content/newsletters/PresseApril2017.pdf?sv=2016-05-31&sr=f&sig=rkQEmY6IWXZqcgvhmm00gLQ%2FCZEq6nsH95S3aP9T72A%3D&se=2017-05-01T11:46:18Z&sp=r&xyz=timestamp of client
This will ensure browser is not caching and hence conditional headers will not be added
Upvotes: 7
Reputation: 1061
I think you need to set the CORS rule for your share
or you might have uploaded an empty file.
Upvotes: 0
Reputation: 1515
There is noting wrong or any issue with Azure file storage, its because of some proxy/cache server. You can use following solution.
/// token = SharedAccessSignature
string tick = $"&{ DateTimeOffset.UtcNow.Ticks}";
Uri url = new Uri(file.StorageUri.PrimaryUri.ToString() + token + tick);
Upvotes: 4
Reputation: 24539
Azure File Storage Error: Condition Headers Are Not Supported
Since the new Edge browser will not have any support for ActiveX plug-ins. Therefore, Acrobat/Reader plug-in won't work with Edge. We can get more details for Change in support for Acrobat and Reader plug-ins in modern web browsers and Microsoft Edge: Building a safer browser.
Edit:
If we try to download the PDF file with Edge in the private and develop mode, we can get the error message "Something’s keeping this PDF from opening" and also can know that edge browser has sent 2 requests. And second request with Header 'If-range
'. According the Azure file storage Get File API, there is no specifying Conditional Headers If-Range
supported. I also find a similar issue about edge browser.
I also test in the Firefox and Chrome, then just get the 1 request.
Note: For Azure Blob Service, the pdf file can be opened correctly from the edge browser. As Blob Get Blob API that supports a successful operation to read the full blob returns status code 200 (OK) and a successful operation to read a specified range returns status code 206 (Partial Content).
Upvotes: 2