I've been banging my head against the wall with this for a few hours now and I can't seem to figure out what's wrong.
Basically I have a S3 Bucket and I'm trying to upload a simple text (.txt) file to it from Unity3D. The C# script to download and PHP script are taken from here
So I put the PHP script in the bucket itself, get the URL of that php script and call it from the C# code:
PHP script:
<?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);
I get the error "Error during upload: 405 Method not allowed"
I tried changing permission settings, Region settings, etc but to no avail.
I read this answer and it mentioned to change the end point but I can't seem to do that there's no way to edit it.
If I try the same PHP/C# script on a different server it works fine... But just not in the S3 Bucket.
I've tried another PHP/C# script and got the same result, same error on the S3 bucket but success on a different server.
Here's the other PHP script I tried:
<?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";
}
(The C# code used with this script does something similar to the previously posted C# code)
Thanks for any help in advance