blogapi_metaweblog_new_media_object

Definition

blogapi_metaweblog_new_media_object($blogid, $username, $password, $file)
modules/blogapi.module, line 343

Description

Blogging API callback. Inserts a file into Drupal.

Code

<?php
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');
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.