Amazon, SimpleDB, and Base64

November 11th, 2008

The other day I made some changes to the way I am storing data in SimpleDB, part of Amazon Web Services. Instead of storing one data field per attribute, I store several delimited data fields in one attribute, which is more efficient for my needs. I used to use a ~ as a delimiter, but I decided to change the delimiter to a non-printable character code. Suddenly, my data was not returning the way I had saved it and my application was choking on it.

It turns out that Amazon changed the way they handle data storage a few months ago. It didn’t apply to me at the time I read the release notes, so I skipped over it. If there is a non-standard XML character in your data, they will automatically Base64 encode it. Took a while to figure this out. I decided to base64 encode when saving the delimited data and base64 decode upon retrieval. This way, I am not relying on Amazon to provide only encoded data. It is better to have the same data return as what you put in.

Upgrading Flex Builder to Flex SDK 3.1

November 11th, 2008

Maybe I am not subscribed to the proper notifications, but until last night I had no idea that there was a new Flex SDK version. You would think that since I purchased the application, my email address would become part of a notification list for upgrades. They certainly email me frequently about Creative Suite upgrades. Who knows.

I was having an issue where when I right-clicked on my episend message elements, the cursor would disappear after the menu went away. I tried all different combinations of CursorManager.ShowCursor(), CursorManager.RemoveAllCursors(), and Mouse.Show() in all different events. Nothing. So I did a search in Google and came across a list of bugs that was fixed in SDK 3.1. Wait a minute. Fixed as in past tense as in 3.1 already exists.

So I did a search for Flex SDK 3.1 and found the general Flex download page where you can download the Flex SDK or a trial version of Flex Builder. I couldn’t find much about upgrading an existing FlexBuilder installation to SDK 3.1. They have a page where Matt Chotin talks about upgrading to Air 1.1 (http://www.adobe.com/devnet/flex/articles/flex_air1.1.html and on that page he links to instructions for upgrading your SDK, but it must be a wrong link because I did not see instructions on the page he provided: http://livedocs.adobe.com/flex/3/html/build_6.html#162812. So I will give you the process I took to upgrade my SDK. It worked on both my home machine and office machine, one XP and the other Vista.

1) Download the 3.1 SDK zip file to your PC. The direct link to the SDK is:
http://download.macromedia.com/pub/flex/sdk/flex_sdk_3.zip

If that link doesn’t work for you, go to the general download page (http://www.adobe.com/products/flex/flexdownloads/), check the box that you agree to whatever they are asking you to agree to, and download the SDK.

2) Close Flex Builder and any running Flex or Air apps you have running.

3) Hopefully you have WinZip or another such unzipping tool and aren’t relying on the built-in Windows unzipper. You want to unzip the contents of the zip file, while preserving the directory structure and overwriting existing folders and files, to the SDK directory in your Flex setup. For me, this was c:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0 .

4) Launch Flex Builder and verify the new version by right clicking a project, clicking Properties, and selecting Flex Compiler. You should see “currently ‘Flex 3.1′” as your SDK version in the right hand pane.

5) Read Matt Chotin’s page (linked to above) to see if any of the manual post-upgrade procedures apply to you. They did not apply to me.

Good luck.

Sorting in Amazon SDB

October 28th, 2008

In July, Amazon Web Services released the ability to sort on SimpleDB queries. Prior to that, there was no guarantee of what order your result sets would come back in.

The syntax is pretty straightforward, just add sort asc or sort desc to the end of your query. The catch is that you have to include the attribute you want to sort on in your query. So you can’t do something like this:


['UserID' = '{$userID}'] sort 'SaveDate' desc

Simple DB throws an error. What you need to do is artificially add your sort attribute to the end of the query, like so:


['UserID' = '{$userID}'] intersection ['SaveDate' > ''] sort 'SaveDate' desc

The UserID query will be unaffected and your results will be sorted by SaveDate.