Programming Amazon Web Services
Programming Amazon Web Services S3, EC2, SQS, FPS, and SimpleDB By James Murty
March 2008
Pages: 600


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Can't Get Past Example 2-2
kwcloud
post Mar 27 2009, 12:50 PM
Post #1


New Member
*

Group: Members
Posts: 2
Joined: 27-March 09
Member No.: 17,282



I set up AWS.rb with Examples 2-1 and 2-2 and inputed the example then get the error message -

NoMethodError: undefined method 'encode_base64' for #<Object:0xb7c709a4 @aws_secret_key="MySecretKey"> from .... in 'generate_signature'

Any thoughts?

Go to the top of the page
 
+Quote Post
JamesMurty
post Mar 28 2009, 07:14 PM
Post #2


Active Member
**

Group: Members
Posts: 20
Joined: 20-March 08
Member No.: 161



The encode_base64 method is not defined until Example 2-10 (Utility Methods), but I neglected to mention this correctly at this point in the chapter. Sorry about that.

You can either skip ahead to Example 2-10 to find the full implementation of this method, or you can temporary replace the call to the encode_base64 method with the following:

b64_sig = Base64.encode64(digest)

We added the encode_base64 method relatively late in the development of the book, after we discovered that the default Ruby base 64 encoding method (as listed above) adds newline characters to the result. These characters cause issues for the Amazon services discussed later in the book. I intended to add a reference to Example 2-10 before the test script listing, but this line mistakenly refers to Example 2-2.

Thanks for reporting the issue. I hope this explanation and work-around helps.

Regards,
James

P.S. Don't forget that all the example code is available for download, to save you typing it all out. You can find the code archive here: http://examples.oreilly.com/9780596515812/

This post has been edited by James Murty: Mar 28 2009, 07:29 PM
Go to the top of the page
 
+Quote Post
JamesMurty
post Mar 28 2009, 07:26 PM
Post #3


Active Member
**

Group: Members
Posts: 20
Joined: 20-March 08
Member No.: 161



The book includes the following statement on page 29, just after Example 2-2:

Be sure to implement the encode_base64 method in Example 2-2 before you perform this test.

This reference is incorrect and should point the reader to Example 2-10, which is where the encode_base64 method is defined. I have added a new entry to the book's errata for this error.
Go to the top of the page
 
+Quote Post
kwcloud
post Mar 30 2009, 03:50 PM
Post #4


New Member
*

Group: Members
Posts: 2
Joined: 27-March 09
Member No.: 17,282



Thanks for the quick response, James. Your post worked for me.

I am new to Ruby so I like to type in the examples in the book, or any book like this when I am learning. Typing in all the examples helps me to learn the topic and the programming language. Usually I make a typo or two so I get to learn error messages, troubleshooting and debugging. I have downloaded the code but I haven't used it yet other than to double check examples 2-1 and 2-2. If I download and just use your code then I don't really learn anything.

Love the book.

Thanks again.



QUOTE (James Murty @ Mar 28 2009, 07:14 PM) *
The encode_base64 method is not defined until Example 2-10 (Utility Methods), but I neglected to mention this correctly at this point in the chapter. Sorry about that.

You can either skip ahead to Example 2-10 to find the full implementation of this method, or you can temporary replace the call to the encode_base64 method with the following:

b64_sig = Base64.encode64(digest)

We added the encode_base64 method relatively late in the development of the book, after we discovered that the default Ruby base 64 encoding method (as listed above) adds newline characters to the result. These characters cause issues for the Amazon services discussed later in the book. I intended to add a reference to Example 2-10 before the test script listing, but this line mistakenly refers to Example 2-2.

Thanks for reporting the issue. I hope this explanation and work-around helps.

Regards,
James

P.S. Don't forget that all the example code is available for download, to save you typing it all out. You can find the code archive here: http://examples.oreilly.com/9780596515812/

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 7th November 2009 - 12:32 PM