Amazon S3-405方法不允许使用POST(尽管我在存储桶中允许POST) [英] Amazon S3 - 405 Method Not allowed using POST (Although I allowed POST on the bucket)

查看:510
本文介绍了Amazon S3-405方法不允许使用POST(尽管我在存储桶中允许POST)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个问题,我的图表(使用AJAX-POST-PHP)没有出现在亚马逊上

I am facing a problem that my graph (Using AJAX - POST - PHP) is not appearing on Amazon

http://cdpmotest.s3-website.eu-central-1 .amazonaws.com/

它说(错误的方法405错误)

its says (Wrong Method 405 Error)

这是我的CORS配置:

This is my CORS Config :

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

这是我的脚本:

<script>
$(document).ready(function(){
     var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
     $.ajax({
         url: 'graph-data.php',
         type: 'POST',
         dataType: 'json',
         success: function(data) {
              var array1 = data.map(function(item) {
                  return parseInt(item[1], 10);
              });
              var array2 = data.map(function(item) {
                  return parseInt(item[2], 10);
              });

              createGraph(array1, array2);
         }
     });//end AJAX request

function createGraph(array1, array2) {
     var ctx = document.getElementById("chart-area1").getContext("2d");
     var barChartData = {
     labels : ["Land Acquisition","Design Concept","Permits and  Licensing","Tendering","Elec.+Water Requests","Construction Start","Construction Finish","Site Handover"],
     datasets : [
     {
          fillColor : "rgba(0,154,166,0.5)",
          strokeColor : "rgba(0,154,166,0.8)",
          highlightFill: "rgba(0,154,166,0.75)",
          highlightStroke: "rgba(0,154,166,1)",
          data : array1
     },
     {
          fillColor : "rgba(77,79,83,0.5)",
          strokeColor : "rgba(77,79,83,0.8)",
          highlightFill : "rgba(77,79,83,0.75)",
          highlightStroke : "rgba(77,79,83,1)",
          data : array2
    }
    ]
    }//end bar chart data

    window.myBar = new Chart(ctx).Bar(barChartData, {
        responsive : true
    });
    }//end createGraph
    });
    </script>

它在localhost(WAMPServer)上正常工作

Its working fine on localhost (WAMPServer)

你能帮我吗?

推荐答案

该错误的直接原因与CORS无关,实际上是由S3网站终结点不支持POST(仅REST端点支持它,但这实际上与手头的问题无关.

The direct cause of the error is unrelated to CORS, and is actually caused by the fact that that the S3 website endpoints don't support POST (only the REST endpoints support it, but that's not actually related to the problem at hand).

真正的问题是,您似乎试图将S3用于它不能做的事情.

The real problem is that you appear to be trying to use S3 for something it doesn't do.

 $.ajax({
     url: 'graph-data.php',
     type: 'POST',

S3是对象存储,而不是应用程序服务器.

S3 is an object store, not an application server.

您无法在S3上运行php.您无法在S3上执行任何服务器端代码.

You can't run php on S3. You can't execute any server-side code on S3.

您可以在Amazon S3上托管静态网站.在静态网站上,单个网页包含静态内容.它们也可能包含客户端脚本.相比之下,动态网站依赖服务器端处理,包括服务器端脚本,例如PHP,JSP或ASP.NET. Amazon S3不支持服务器端脚本.

You can host a static website on Amazon S3. On a static website, individual web pages include static content. They may also contain client-side scripts. By contrast, a dynamic website relies on server-side processing, including server-side scripts such as PHP, JSP, or ASP.NET. Amazon S3 does not support server-side scripting.

http://docs.aws.amazon.com/AmazonS3/Latest/dev/WebsiteHosting.html

文档的同一页将为您提供替代AWS解决方案,以实现所需的功能.

That same page of the documentation will point you to alternative AWS solutions for accomplishing what you want.

这篇关于Amazon S3-405方法不允许使用POST(尽管我在存储桶中允许POST)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆