问题
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
回答1:
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).
回答2:
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);
回答3:
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
回答4:
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"
});
回答5:
I think you need to set the CORS rule for your share
https://docs.microsoft.com/en-us/rest/api/storageservices/cross-origin-resource-sharing--cors--support-for-the-azure-storage-services
or you might have uploaded an empty file.
回答6:
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
.
- You can do this for new files during upload by setting the Properties of the File.
- For existing files, they can be updated via a Powershell script, or one by one using Storage Explorer. You'll need to clear your browser cache to remove existing cached header information.
来源:https://stackoverflow.com/questions/43706605/azure-file-storage-error-condition-headers-are-not-supported