+ $this->initDocument($this->format);
+ switch ($this->format) {
+ case 'json':
+ return $this->showResponseJson($upload);
+ case 'xml':
+ return $this->showResponseXml($upload);
+ default:
+ throw new ClientException('This API call does not support the format '._ve($this->format));
+ }
+ $this->endDocument($this->format);
+ }
+
+ protected function showResponseJson(MediaFile $upload)
+ {
+ $enc = $upload->fileRecord->getEnclosure();
+
+ // note that we use media_id instead of mediaid which XML users might've gotten used to (nowadays we service media_id in both!)
+ $output = [
+ 'media_id' => $upload->fileRecord->id,
+ 'media_id_string' => (string)$upload->fileRecord->id,
+ 'media_url' => $upload->shortUrl(),
+ 'size' => $upload->fileRecord->size,
+ ];
+ if (common_get_mime_media($enc->mimetype) === 'image') {
+ $output['image'] = [
+ 'w' => $enc->width,
+ 'h' => $enc->height,
+ 'image_type' => $enc->mimetype,
+ ];
+ }
+ print json_encode($output);
+ }
+
+ protected function showResponseXml(MediaFile $upload)
+ {
+ $this->elementStart('rsp', array('stat' => 'ok', 'xmlns:atom'=>Activity::ATOM));