Quantcast

Xamarin - Amazon S3

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Xamarin - Amazon S3

c.hermann

Hi,

 

i`am trying to connect to amazon S3 with this: https://github.com/xamarin/amazon

 

this is my testcode:

 

  public static AmazonS3 client;

        protected override void OnCreate(Bundle bundle)

        {

            base.OnCreate(bundle);

 

            SetContentView(Resource.Layout.Main);

 

            Android.Util.Log.Debug("AMAZON:", "START");

 

            if (true)

            {

                Android.Util.Log.Debug("AMAZON:", "CHECK");

                using (client = Amazon.AWSClientFactory.CreateAmazonS3Client("keykeykeykekyekykekykeky ", "keykeykeykekyekykekykeky"))

                {

                    Android.Util.Log.Debug("AMAZON:", "USING");

                    try

                    {

                        using (ListBucketsResponse response = client.ListBuckets())

                        {

                            foreach (S3Bucket bucket in response.Buckets)

                            {

                                Android.Util.Log.Debug("AMAZON:", bucket.BucketName);

 

                            }

                        }

                    }

                    catch (AmazonS3Exception amazonS3Exception)

                    {

                        if (amazonS3Exception.ErrorCode != null &&

                            (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||

                            amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))

                        {

                            Android.Util.Log.Debug("AMAZON:", "E1");

                        }

                        else

                        {

                            Android.Util.Log.Debug("AMAZON:", amazonS3Exception.ErrorCode + " - " + amazonS3Exception.Message);

                        }

                    }

                }

            }

        }

 

 

But i always get an error at this line: using (ListBucketsResponse response = client.ListBuckets())

 

System.NullReferenceException: Object reference not set to an instance of an object

 

 

Any ideas? :D

 

Kind regards chris

 


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Xamarin - Amazon S3

Jonathan Pryor-2
On Nov 28, 2012, at 9:19 AM, Christian Hermann <[hidden email]> wrote:
...
> But i always get an error at this line: using (ListBucketsResponse response = client.ListBuckets())
>  
> System.NullReferenceException: Object reference not set to an instance of an object

What's the full stack trace?

There are two possibilities:

1. Amazon.AWSClientFactory.CreateAmazonS3Client() is returning null.
2. AmazonS3.ListBuckets() is internally hitting a NRE.

(1) is unlikely, given that the source always creates a new instance:

        https://github.com/xamarin/amazon/blob/master/AWSSDK/AWSClientFactory.cs#L1221

(2) is possible, and a full stack trace would be able to confirm or deny this.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Xamarin - Amazon S3

c.hermann
Hi Jon,

i get following exception:

11-29 07:52:09.794: D/AMAZON:(8194): GO
11-29 07:52:09.794: D/AMAZON:(8194): CHECK
11-29 07:52:09.919: D/AMAZON:(8194): USING
11-29 07:53:32.848: D/AMAZON:(9021): GO
11-29 07:53:32.848: D/AMAZON:(9021): CHECK
11-29 07:53:32.989: D/AMAZON:(9021): USING
11-29 07:53:36.684: D/AMAZON:(9021): Object reference not set to an instance of an object -   at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.transform (System.String responseBody, System.String actionName, System.Type t) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.processRequestResponse[ListBucketsResponse] (System.Net.HttpWebResponse httpResponse, Amazon.S3.Model.S3Request request, System.Type t, Amazon.S3.Model.ListBucketsResponse& response, System.Exception& cause) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.handleHttpResponse[ListBucketsResponse] (Amazon.S3.Model.S3Request userRequest, System.Net.HttpWebRequest request, System.Net.HttpWebResponse httpResponse, Int32 retries, Int64 lengthOfRequest, Amazon.S3.Model.ListBucketsResponse& response, System.Exception& cause, System.Net.HttpStatusCode& statusCode) [0x00000] in <filename unknown>:0
11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.getResponseCallback[ListBucketsResponse] (IAsyncResult result) [0x00000] in <filename unknown>:0


Chris :)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Xamarin - Amazon S3

Jonathan Pryor-2
On Nov 29, 2012, at 1:58 AM, c.hermann <[hidden email]> wrote:

> i get following exception:
>
> 11-29 07:53:36.684: D/AMAZON:(9021): Object reference not set to an instance of an object -   at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at System.Xml.XmlInputStream..ctor(System.IO.Stream stream)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at System.Xml.XmlStreamReader..ctor(System.IO.Stream input)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at System.Xml.XmlTextReader..ctor(System.IO.Stream input)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.transform(System.String responseBody, System.String actionName, System.Type t)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.processRequestResponse[ListBucketsResponse](System.Net.HttpWebResponse httpResponse, Amazon.S3.Model.S3Request request, System.Type t, Amazon.S3.Model.ListBucketsResponse& response, System.Exception& cause)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.handleHttpResponse[ListBucketsResponse](Amazon.S3.Model.S3Request userRequest, System.Net.HttpWebRequest request, System.Net.HttpWebResponse httpResponse, Int32 retries, Int64 lengthOfRequest, Amazon.S3.Model.ListBucketsResponse& response, System.Exception& cause, System.Net.HttpStatusCode& statusCode)
> 11-29 07:53:36.684: D/AMAZON:(9021):   at Amazon.S3.AmazonS3Client.getResponseCallback[ListBucketsResponse](IAsyncResult result)

Conjecture: (2) AmazonS3.ListBuckets() is internally hitting a NRE. I think the conjecture is confirmed. :-)

Specifically, XmlInputStream(Stream) is being given a null Stream, and blows up when attempting to call stream.Read():

        https://github.com/mono/mono/blob/mono-2-10/mcs/class/System.XML/System.Xml/XmlInputStream.cs#L389

(The perils of not null-checking arguments...)

As for _why_ AmazonS3.ListBuckets() is passing XmlInputStream a null stream...I have no idea. Perhaps one of the "buckets" is malformed? You'll need to investigate the AmazonS3 library to determine the cause and solution.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Xamarin - Amazon S3

spcware
I believe it is a runtim error with the Xamarin version of Amazon AWS SDK.  The SDK uses XSLT files at runtime to process the XML responses and the Xamarin version of Amazon AWS SDK does NOT include the XSLT in the project as EmbeddedResources.  Set all XSLT files as EmbeddedResources and rebuild the Xamarin version of Amazon AWS SDK and it should work.
Loading...