xamarin / amazon

Library for accessing Amazon web services from mobile apps
62 stars 48 forks source link

S3 Client - missing resource file? #2

Closed JuggernautInteractive closed 11 years ago

JuggernautInteractive commented 11 years ago

Hi guys, I just started using the S3 client and it's throwing a null stream exception when trying to parse the response, or transform it rather. seems to be looking for an embedded xslt file?

issue occurs here: File: /amazon-master/AWSSDK/Amazon.S3/AmazonS3Client.cs Line 6667: string transform(string responseBody, string actionName, Type t)

Here's the client calling code: var client = Amazon.AWSClientFactory.CreateAmazonS3Client("", "");
var bucketList = client.ListBuckets().Buckets; foreach (Amazon.S3.Model.S3Bucket b in bucketList) {
Console.WriteLine(b.BucketName);
}

Which gives this Exception Stack:

[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x0001e] in /Developer/MonoTouch/Source/mono/mcs/class/System.XML/System.Xml/XmlInputStream.cs:389 at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00006] in /Developer/MonoTouch/Source/mono/mcs/class/System.XML/System.Xml/XmlInputStream.cs:362 at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in :0 at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in :0 at Amazon.S3.AmazonS3Client.transform (System.String responseBody, System.String actionName, System.Type t) [0x0008d] in /Users/duggernaut/Code/MonoTouch/OpenSource/amazon-master/AWSSDK/Amazon.S3/AmazonS3Client.cs:6694 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) [0x0025a] in /Users/duggernaut/Code/MonoTouch/OpenSource/amazon-master/AWSSDK/Amazon.S3/AmazonS3Client.cs:6285 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) [0x000a5] in /Users/duggernaut/Code/MonoTouch/OpenSource/amazon-master/AWSSDK/Amazon.S3/AmazonS3Client.cs:6086 at Amazon.S3.AmazonS3Client.getResponseCallback[ListBucketsResponse](IAsyncResult result) [0x000aa] in /Users/duggernaut/Code/MonoTouch/OpenSource/amazon-master/AWSSDK/Amazon.S3/AmazonS3Client.cs:5822

any ideas?

andres-asm commented 11 years ago

The object is not missing, If you check the AWSSDK/Amazon.S3/Model you can see the file is there

quoting from another bug report:

"The problem for MonoTouch is that it is not possible to execute code dynamically like this, it has to be compiled (to native code) into the app before installing the app on a device (this is an iOS restriction), so this will unfortunately not be fixed."

long story short, I think this method (and many others) would have to be reimplemented for this to work.

JuggernautInteractive commented 11 years ago

forgot to mention... I am getting a response from AWS ListBuckets, here's the "responseBody" param going into the transform string method.

<?xml version="1.0" encoding="UTF-8"?>

31e36698aad00324c28f11acf1ba060171feb59c3ae4dae9ba8c02b3bea0ff4dbehrappsakiaiishqm3da7qj6rsacomhaystacksoftwarearq2012-04-16T15:16:53.000Zji-test-bucket2012-11-27T00:39:17.000Zjuggernaut.4112012-05-01T13:38:31.000Zjuggernaut.apps2011-07-26T01:22:33.000Zjuggernaut.corporate2011-09-13T15:25:20.000Zjuggernaut.jdrive2011-05-26T23:24:43.000Zjuggernaut.video2012-10-16T18:46:17.000Z
JuggernautInteractive commented 11 years ago

thanks for the tips, I'll see if I can hack around the parts I need for my test app.

Clancey commented 11 years ago

I just pushed a fix. I no longer get that error.

andres-asm commented 11 years ago

Wow the fix was so simple... I thought it was a very different matter.

JuggernautInteractive commented 11 years ago

bOoM! thanks for the fix, it's working :+1:

nice work gents, you guys are why this community is so great :)

ghost commented 11 years ago

I'm still experiencing this issue in my MonoDroid application. Was a similar fix pushed for the Android project awhile back?

Here's my code:

AmazonS3 client = AWSClientFactory.CreateAmazonS3Client (ACCESS_KEY, SECRET_KEY); ListObjectsRequest listObjectsRequest = new ListObjectsRequest ().WithBucketName (BUCKET_NAME); ListObjectsResponse listObjectsResponse = client.ListObjects (listObjectsRequest);

Here's the error I get when I step through to the next line:

Object reference not set to an instance of an object at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x00000] in :0 at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00000] in :0 at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in :0 at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in :0 at Amazon.S3.AmazonS3Client.transform (System.String responseBody, System.String actionName, System.Type t) [0x00000] in :0 at Amazon.S3.AmazonS3Client.processRequestResponse[ListObjectsResponse](System.Net.HttpWebResponse httpResponse, Amazon.S3.Model.S3Request request, System.Type t, Amazon.S3.Model.ListObjectsResponse& response, System.Exception& cause) [0x00000] in :0 at Amazon.S3.AmazonS3Client.handleHttpResponse[ListObjectsResponse](Amazon.S3.Model.S3Request userRequest, System.Net.HttpWebRequest request, System.Net.HttpWebResponse httpResponse, Int32 retries, Int64 lengthOfRequest, Amazon.S3.Model.ListObjectsResponse& response, System.Exception& cause, System.Net.HttpStatusCode& statusCode) [0x00000] in :0 at Amazon.S3.AmazonS3Client.getResponseCallback[ListObjectsResponse](IAsyncResult result) [0x00000] in :0