Monday, November 08, 2010 at 12:05 AM.

on newMediaObject (blogid, username, password, struct) {
		<<9/9/04; 9:07:07 PM by SK
			<<Added code to determine media type.  If it's an image, place the new media object in Radio's default image directory.  Everything else, place in the gems directory.
		<<1/11/03; 5:31:47 PM by JES
			<<Added code to get the MacOS type/creator.
		<<1/10/03; 8:22:39 AM by DW
	radio.weblog.bloggerApi.checkUser (client, true, username, password);
	radio.weblog.bloggerApi.checkBlogid (blogid);
	local (name =;
	bundle { //add extension to name
		if not (name contains ".") {
			local (adr, type = string.lower (struct.type));
			for adr in @user.webserver.prefs.ext2MIME {
				if type == string.lower (adr^) {
					name = name + "." + nameof (adr^);
	local (type = '    ', creator = '    ');
	if system.environment.isMac { //get mac type/creator
		local (adrtype, mimetype = string.lower (struct.type));
		for adrtype in @user.webserver.prefs.type2Mime {
			if string.lower (adrtype^) == mimetype {
				type = nameOf (adrtype^);
				if string.lower (adrtype^) beginsWith "image/" {
					creator = user.html.prefs.imgFileCreator}}}};
	//determine filesystem destination--parse text for, convert slashes to correct file.getPathChar and assign to a variable "name"
	if system.environment.isMac {
		name = string.replaceAll (name, "/", ":")}
	else {
		name = string.replaceAll (name, "/", "\\")};
	local (f); //f is the upstreamed file location for Radio weblogs--images for images, gems for everything else
	if struct.type contains "image" {
		f = + + file.getPathChar () + name;
		if file.sureFilePath (f) {
			file.writewholefile (f, struct.bits, type, creator)}
		else {
			file.newFolder (f)}}
		<<file.writewholefile (f, struct.bits, type, creator)
	else {
		f = + + file.getPathChar () + name;
		file.writewholefile (f, struct.bits, type, creator)};
	local (returnedstruct);
	new (tabletype, @returnedstruct);
	returnedstruct.url = radio.upstream.getFileUrl (f);
	return (returnedstruct)}
<<bundle //test code
	<<local (struct, client = "")
	<<bundle //set up struct
		<<new (tabletype, @struct)
		<< = "steve-suit.jpg"
		<<struct.type = user.webserver.prefs.ext2MIME.jpeg
		<<struct.bits = binary (file.readwholefile ("C:\\Documents and Settings\\skirks\\My Pictures\\stevesmile.jpg"))
	<<newMediaObject ("home",,, struct)

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.