
The XML-RPC calls work as described by the documentation and examples, but they make no mention of what to do if you need to send Base64 dataFor a while it looked like I might actually be able to consolidate my current Rube Goldberg iPhoto to Movable Type solution into a single AppleScript, thanks to OS X's AppleScript Support for Remote Procedure Calls.
The XML-RPC calls work as described by the documentation and examples, but they make no mention of what to do if you need to send Base64 data; in my own tests of the Movable Type metaWeblog.newMediaObject method, a base64 encoded string simply gets handled as a plain text string on the other side, and gets written directly to the file.
On a hunch I tried passing the raw file data as an AppleScript data variable, hoping against hope that the Apple Event handler would take care of the encoding on the fly, but as far as I can tell the raw data also gets passed along as a string, leading to a munged XML-RPC message.
And naturally, there's absolutely nothing out there on the web or usenet regarding this issue... I can't believe I'm the first person to try this, but perhaps those before me have given up in disgust before getting as far as writing about it.
I dropped the good folks at developer.apple.com a note regarding the documentation, politely suggesting that some clarification would be very helpful.. we'll see what happens.
In the meantime, I may as well make the XML-RPC call via PHP with a do shell script statement.
If anyone who comes across this has a solution, I would be most grateful if you could drop me a line with a quick code snippet.
Adapted from the 'Photo Summary' Apple's iPhoto Scripts Collection, here's a script that will set the comment of all currently selected photos at once; handy if you want to enter some common information about a bunch of photos, for example 'Family Reunion 2004 in Mayor's Income, Tennessee'
Adapted from the 'Photo Summary' Apple's iPhoto Scripts Collection, here's a script that will set the title of each selected photo incrementally; so if you have three photos selected and you enter 'My Kickass Photo' as the base title, the photo titles will be set to 'My Kickass Photo (1)', 'My Kickass Photo (2)', and 'My Kickass Photo (3)'.
Route 10 Swanzey, New Hampshire
(Demolished in 2009)
Main Street at West River Street
Orange, Massachusetts
Basic usage:
Encode | /path/to/base64 -e 'The quick brown fox' /path/to/base64 'The quick brown fox' |
Decode | /path/to/base64 -d VGhlIHF1aWNrIGJyb3duIGZveA== |
Help | /path/to/base64 -h |
This has to be just about my biggest Usenet programming language newsgroup pet peeve of all time - the classic
You don't want to do that. Never mind that you really do want to do that, I've decided that you don't.
In my ongoing attempt to perfect my iPhoto to Movable Type solution, I ran into the need to convert a Unix path (/tmp/foo.jpg) into an HFS style path (Mac HD:tmp:foo.jpg) that plays nicely with AppleScript's 'read' command.
Apparently this isn't all that common an issue, since file paths tend to be grabbed programmatically by AppleScript... but because I'm doing stuff with shell commands I'm working with Unix paths.
After much Googling, I found my answer in the first comment of a post on macosxhints.com.
In a nutshell, to convert a string representing a Unix file path into an HFS file path, do like so:
posix file "/path/to/my/file.txt"
This is probably not news to anybody who actually knows AppleScript, but I'm still stumbling my way along, grabbing other people's code and making educated guesses. The plain English style syntax is disconcerting.