我正在尝试使用Windows Azure的PHP SDK--它不支持CORS,也不支持共享访问密钥。CORS和Azure存储(PHP)
重写SDK以允许我生成SAS和必需的查询字符串,并且为感恩更新重写它,允许CORS通过REST API更新到存储,我已经达到了一个卡住点。
我成功地创建了SAS,并可以通过它们读取文件。 同样,我的CORS请求如下:
<StorageServiceProperties>
<Cors>
<CorsRule>
<AllowedOrigins>
*
</AllowedOrigins>
<AllowedMethods>
GET, PUT, POST, DELETE, HEAD, OPTIONS
</AllowedMethods>
<MaxAgeInSeconds>
500
</MaxAgeInSeconds>
<ExposedHeaders>
x-ms-meta-data*,x-ms-meta-customheader
</ExposedHeaders>
<AllowedHeaders>
x-ms-meta-target*,x-ms-meta-customheader
</AllowedHeaders>
</CorsRule>
</Cors>
<DefaultServiceVersion>
2013-08-15
</DefaultServiceVersion>
</StorageServiceProperties>
对此我接收响应HTTP_Request2_Response Object ([version:protected] => 1.1 [code:protected] => 202 [reasonPhrase:protected] => Accepted [effectiveUrl:protected] => <mysite>?restype=service&comp=properties [headers:protected] => Array ([transfer-encoding] => chunked [server] => Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 [x-ms-request-id] => 59bc0e05-4767-4953-9df1-2d2a6a9054bc [x-ms-version] => 2013-08-15 [date] => Fri, 13 Dec 2013 11:23:49 GMT) [cookies:protected] => Array () [lastHeader:protected] => date [body:protected] => [bodyEncoded:protected] => 1)
我还通过malforming输入的任何部分检查,并且它确实发生故障,并发送400个失败响应。
所以,现在我写在我的网页应用程序应该允许用户直接将文件上传到存储帐户,但我仍然收到错误
OPTIONS <mystorage> 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.) jquery.js:8706 OPTIONS <mystorage> No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<mysite>' is therefore not allowed access. jquery.js:8706 XMLHttpRequest cannot load <mystorage>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin <mysite> is therefore not allowed access. azure_blob.html:1 error
而且我不知道从哪里继续从这里开始......我觉得我已经启用了CORS,而且我觉得自己有SAS工作,但它告诉我CORS支持已关闭,但我不确定如何检查是否属实通过REST API/Azure SDK
编辑:感谢Guarav ...问题确实加入content-type
我的头文件
对于任何人很快看到这一点:我将修复代码,使其更好,然后执行其他一些操作,然后向PHP SDK提交拉请求,以便您不必通过此操作再次。
我只对新更新实现了CORS w /方面。在提交请求之前,我将进入并实现其他serviceProperty更新,也许还有其他一些事情。
一旦你弄清了事情,你应该考虑向[回购](https://github.com/WindowsAzure/azure-sdk-for-php/tree/master)提交一个pull请求。 –