You are here

function blogapi_metaweblog_new_media_object in Drupal 4

Same name and namespace in other branches
  1. 5 modules/blogapi/blogapi.module \blogapi_metaweblog_new_media_object()
  2. 6 modules/blogapi/blogapi.module \blogapi_metaweblog_new_media_object()

Blogging API callback. Inserts a file into Drupal.

1 string reference to 'blogapi_metaweblog_new_media_object'
blogapi_xmlrpc in modules/blogapi.module
Implementation of hook_xmlrpc().

File

modules/blogapi.module, line 361
Enable users to post using applications that support XML-RPC blog APIs.

Code

function blogapi_metaweblog_new_media_object($blogid, $username, $password, $file) {
  $user = blogapi_validate_user($username, $password);
  if (!$user->uid) {
    return blogapi_error($user);
  }
  $name = basename($file['name']);
  $data = $file['bits'];
  if (!$data) {
    return blogapi_error(t('No file sent.'));
  }
  if (!($file = file_save_data($data, $name))) {
    return blogapi_error(t('Error storing file.'));
  }

  // Return the successful result.
  return array(
    'url' => file_create_url($file),
    'struct',
  );
}