exit(1);
}
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
/**
* Upload an image via the API. Returns a shortened URL for the image
* to the user.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class ApiMediaUploadAction extends ApiAuthAction
{
/**
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
_('This method requires a POST.'),
400, $this->format
);
- return;
}
// Workaround for PHP returning empty $_POST and $_FILES when POST
'The server was unable to handle that much POST data (%s bytes) due to its current configuration.',
intval($_SERVER['CONTENT_LENGTH']));
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
- return;
}
$upload = null;
try {
- $upload = MediaFile::fromUpload('media', $this->auth_user);
+ $upload = MediaFile::fromUpload('media', $this->auth_user->getProfile());
} catch (Exception $e) {
$this->clientError($e->getMessage(), $e->getCode());
- return;
}
if (isset($upload)) {
$this->showResponse($upload);
} else {
+ // TRANS: Client error displayed when uploading a media file has failed.
$this->clientError(_('Upload failed.'));
- return;
}
}
* Overrided clientError to show a more Twitpic-like error
*
* @param String $msg an error message
- *
*/
function clientError($msg)
{
$this->elementEnd('rsp');
$this->endDocument();
}
-
}