Can´t upload an aws bucket

I´m trying to upload an aws bucket but I got this error :
Exception ocurred during uploading: Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type ‘Amazon.Runtime.Internal.HttpErrorResponseException’ was thrown.
at Amazon.Runtime.Internal.UnityRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x0000e] in :0
at Amazon.S3.AmazonS3Client.ProcessPostResponse (System.IAsyncResult result) [0x0001c] in :0
UnityEngine.Debug:Log(Object)
<>c:b__10_0(AmazonServiceResult`2) (at Assets/Scripts/AWSManager.cs:86)
Amazon.S3.<>c__DisplayClass7_0:b__0(AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions)
Amazon.Runtime.Internal.UnityMainThreadDispatcher:ProcessRequests()
Amazon.Runtime.Internal.UnityMainThreadDispatcher:Update()

Here´s my code, can anybody help ?

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.Runtime;
using System.IO;
using System;
using Amazon.S3.Util;
using System.Collections.Generic;
using Amazon.CognitoIdentity;
using Amazon;
using Facebook.Unity;

public class AWSManager : MonoBehaviour
{
private static AWSManager _instance;
public static AWSManager Instance {
get {
if (_instance == null){
Debug.LogError(“AWS Manager is null”);
}
return _instance;
}
}

public string S3Region = RegionEndpoint.USEast2.SystemName;
private RegionEndpoint _S3Region {
get { return RegionEndpoint.GetBySystemName(S3Region); }
}

private AmazonS3Client _s3Client;
public AmazonS3Client S3Client {
get {
if (_s3Client == null){
_s3Client = new AmazonS3Client(new CognitoAWSCredentials (
“us-east-2:0267fa51-2e5f-44d5-80e3-f812fdc5ed20”, //Identity Pool ID
RegionEndpoint.USEast2 //Region
), _S3Region);
}
return _s3Client;
}
}

private void Awake(){

_instance = this;

UnityInitializer.AttachToGameObject(this.gameObject);
AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest;

// ResultText is a label used for displaying status information
S3Client.ListBucketsAsync(new ListBucketsRequest(), (responseObject) =>
{
if (responseObject.Exception == null)
{
responseObject.Response.Buckets.ForEach((s3b) =>
{
print ("Bucket Name: " + s3b.BucketName);
});
}
else
{
print ("AWS Error: " + responseObject.Exception);
}
});

}

public void UploadToS3(string fileName){
FileStream stream = new FileStream(fileName,
FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);

PostObjectRequest request = new PostObjectRequest(){
Bucket = “reservacionfiles”,
Key = fileName,
InputStream = stream,
CannedACL = S3CannedACL.Private,
Region = _S3Region
};

S3Client.PostObjectAsync(request, (responseObj) => {
if (responseObj.Exception == null) {
Debug.Log (“Successfully posted to bucket”);
} else {
Debug.Log ("Exception ocurred during uploading: " + responseObj.Exception);
}
});
}
}

Please use code tags in your post. Your code is unreadable. Also, you probably want to ask Amazon support/community. End finally: it’s definitely not a Unity documentation problem so I cannot imagine how did you select this section of the forum to post.

Hi @Matu007 - as Lurking-Ninja says this isn’t the right place to post this kind of problem. This is the forum to post feedback about the Unity documentation. For help with Amazon AWS i’d recommend trying their own support forums :slight_smile:

1 Like