[英]AWS 405 Method not allowed
我已經用這個把我的頭撞在牆上好幾個小時了,但我似乎無法弄清楚出了什么問題。
基本上,我有一個S3存儲桶,我正嘗試從Unity3D向其中上傳一個簡單的文本(.txt)文件。 從此處獲取要下載的C#腳本和PHP腳本
因此,我將PHP腳本放入了存儲桶本身,獲取了該php腳本的URL,然后從C#代碼進行調用:
PHP腳本:
<?php
if(isset($_FILES['theFile']))
{
print("Success! ");
print("tmpName: " . $_FILES['theFile']['tmp_name'] . " ");
print("size: " . $_FILES['theFile']['size'] . " ");
print("mime: " . $_FILES['theFile']['type'] . " ");
print("name: " . $_FILES['theFile']['name'] . " ");
move_uploaded_file($_FILES['theFile']['tmp_name'], "../images/" . $_FILES['theFile']['name']);
} else
{
print("Failed!");
}
?>
C#:
WWWForm postForm = new WWWForm();
postForm.AddBinaryData("theFile", bytes, "TestFile", "text/plain");
WWW upload = new WWW(phpScriptURL, postForm);
yield return upload;
if (upload.error == null)
Debug.Log("upload done :" + upload.text);
else
Debug.Log("Error during upload: " + upload.error);
我收到錯誤“上傳期間出錯:405方法不允許”
我嘗試更改權限設置,區域設置等,但無濟於事。
我讀了這個答案 ,它提到要更改終點,但我似乎無法做到這一點,無法對其進行編輯。
如果我在不同的服務器上嘗試相同的PHP / C#腳本,則可以正常工作……但不能在S3存儲桶中使用。
我嘗試了另一個PHP / C#腳本,並在S3存儲桶上獲得了相同的結果,相同的錯誤,但在另一台服務器上獲得了成功。
這是我嘗試過的其他PHP腳本:
<?php
$data = file_get_contents('php://input');
try {
$result = file_put_contents("save-bytes.txt", $data, FILE_APPEND);
} catch (Exception $e) {
echo $e->getMessage();
die();
}
if ($result !== false)
{
echo "Saved " . $result . " bytes";
} else {
echo "Data is not saved";
}
(與此腳本一起使用的C#代碼與以前發布的C#代碼具有相似的功能)
感謝您的任何幫助
默認情況下,S3存儲桶被鎖定為私有。 如果要將文件放入存儲桶中,則必須編輯訪問策略。 有關S3存儲桶策略的信息, 請查看docs 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.