Upload to Blog
Here's a quick workflow script written in python to upload an image to your blog.
You'll have to change the parameters at the top to your specific settings, and besides that there are a couple of other requirements:
a) Your weblog system needs to support the metaweblog api (such as movable type)
b) Your workflow image format needs to be set to "PNG"
#!/usr/bin/python
import os
import sys
import xmlrpclib
rpcurl = "http://myhostname.com/mt/mt-xmlrpc.cgi"
blogurl = "http://myhostname.com/mt/"
blogid = "1"
username = "admin"
password = "mypassword"
postTitle = "FlySketch Image Upload"
imagePath = sys.argv[ 1]
metaWeblog = xmlrpclib.Server(rpcurl).metaWeblog
imageStruct = {}
imageStruct['type'] = 'image/png'
imageStruct['name'] = os.path.split(imagePath)1
imageStruct['bits'] = xmlrpclib.Binary(open(imagePath, 'rb').read())
res = metaWeblog.newMediaObject(blogid, username, password, imageStruct)
# we just assume all was well.
url = res['url']
postStruct = {}
postStruct['title'] = postTitle
postStruct['description'] = """<center><img src="%s" alt="%s" /></center>"""
% (url, postTitle)
res = metaWeblog.newPost(blogid, username, password, postStruct, xmlrpclib.Boolean(True))
os.popen('/usr/bin/open ' + blogurl)