Six Apart Developer Center

Developer Center Home » XML-RPC » metaWeblog API »

metaWeblog.newMediaObject

Posted by Byrne Reese on January 16, 2006

Uploads a file to your webserver. If successful, the method will return a URL to the newly created file. Otherwise, a fault will be returned.

Parameters

  • String blogid
  • String username
  • String password
  • struct file

Return value

  • URL to the uploaded file.

Notes

The struct file should contain two keys: base64 bits (the base64-encoded contents of the file) and String name (the name of the file). The type key (media type of the file) is currently ignored.

Sample Request

Sample Response

Perl Code Sample

Comments

Where do the files go on the server?

When I call this method from my client I get an error message: Server returned a fault exception: [1] Error making path ”: mkdir : No such file or directory at /blog-mt/lib/MT/FileMgr/Local.pm line 105

This is using the Yahoo hosted version of MT (3.2).

The answer is that file.name does need to include a server relative path such as “/images/test.gif”.

The second thing I missed in the documentation is that the return value does need to be a struct with a single string property “url”.

The data (“bits”) does need to be Base64 encoded on the wire, but your xml-rpc library may take care of that for you.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.