angularjs - AJAX GET from S3 CORS fails on preflight OPTIONS with 403 -


i saw several issues , talk on this, still couldn't find answer. i'm trying simple file s3 ajax get. bucket configured cors:

<?xml version="1.0" encoding="utf-8"?> <corsconfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">     <corsrule>         <allowedorigin>*</allowedorigin>         <allowedmethod>get</allowedmethod>         <maxageseconds>3000</maxageseconds>         <allowedheader>*</allowedheader>     </corsrule> </corsconfiguration> 

here curl snippet call (omitted file..):

curl 'https://s3.amazonaws.com/mybucket/myfile.tar.gz -x options   -h 'access-control-request-method: get'  -h 'origin: http://0.0.0.0:9000'  -h 'referer: http://0.0.0.0:9000/'  -h 'access-control-request-headers: accept, x-longtostring'   -h 'pragma: no-cache'  -h 'accept-encoding: gzip, deflate, sdch'  -h 'accept-language: en-us,en;q=0.8,he;q=0.6,mg;q=0.4'  -h 'user-agent: mozilla/5.0 (macintosh; intel mac os x 10_10_3) applewebkit/537.36 (khtml, gecko) chrome/44.0.2403.125 safari/537.36'  -h 'accept: */*'  -h 'cache-control: no-cache'  -h 'connection: keep-alive'  --compressed  --verbose 

i 403 result:

 http/1.1 403 forbidden  x-amz-request-id: 1f545b4ed302b3ad  x-amz-id-2: aiqwugoevhfxrjyl/13mlbsuqdx8n4bylhv3twftdfnmz+7fhvnxfvaglco3wcit  content-type: application/xml  transfer-encoding: chunked  date: sun, 30 aug 2015 21:25:17 gmt  server amazons3 not blacklisted  server: amazons3  <?xml version="1.0" encoding="utf-8"?>  connection #0 host s3.amazonaws.com left intact <error><code>accessforbidden</code><message>corsresponse: cors request not allowed. because evalution of origin, request method / access-control-request-method or access-control-requet-headers not whitelisted resource's cors spec.</message><method>get</method></error> 

removing -x options solves this. added automatically browser (i'm using angular $http.get), have no control on (or have i?).

thanks

it seems s3 won't accept options call, in configuration think of. request - if don't add custom header, browser won't trigger options.

so removed custom header specific $http.get(s3filepath) request.

the reason got 403 - because file wasn't ready. after file ready, right.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -