API Reference

Media.getUploadURL

This method provides you with a signed URL that you can then use to upload directly to the Filemobile Amazon bucket where original files are stored, once the upload is complete you must use the media.uploadCompleted method to trigger the system to begin conversion of this file.

The fileData array, must contain type, and filename fields, an example of a valid type would be video/mp4, or image/jpg.

Once you retrieve the URL, you'll need to ensure to send over the proper headers to Amazon with the PUT call.

Those headers are
x-amz-acl: public-read
x-amz-meta-mode:33188
Content-Type: video/mp4

Working PHP Example

$apiUrl='http://api.filemobile.com/services/php';

$sourceFilePath="/tmp/cnTowerImage.jpg";
$sourceFileSize=filesize("/tmp/cnTowerImage.jpg");
$sourceContentType='image/jpg';

$fileData['title']='CN Tower';
$fileData['filename']='cnTowerImage.jpg';
$fileData['message']='Picture of the CN Tower in Toronto , taken during the Blue Jays baseball game';
$fileData['type']=$sourceContentType;

$arguments = array(
  'APIKEY' => '{MYAPIKEY}',
  'method' => 'media.getUploadURL',
  'vhost' => '{MYVHOST}',
  'fileData' => $fileData,
);

$url = $apiUrl .'?' . http_build_query($arguments,null,'&');

$data = file_get_contents($url);

$data = unserialize($data);

$destUrl = 'https://'.urldecode($data['result']['url']);
$mediaID = $data['result']['id'];

$headers= Array("x-amz-acl: public-read", "x-amz-meta-mode: 33188","Content-Type: {$sourceContentType}");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $destUrl);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$fh_res = fopen($sourceFilePath, 'r');
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($sourceFilePath));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_response_res = curl_exec ($ch);
print_r($curl_response_res);
fclose($fh_res);

$arguments = array(
 'APIKEY' => '{MYAPIKEY}',
  'method' => 'media.uploadCompleted',
  'id' => $mediaID 
);
$url = $apiUrl .'?' . http_build_query($arguments,null,'&');

$data = file_get_contents($url);

Syntax

int media.getUploadURL ( int vhost, array fileData, int ttl = 300, int v2 = 0 )

Arguments

NameTypeRequiredDefault valueDescription
vhostintRequirednoneThe vhost ID.
fileDataarrayRequirednoneAn array with file information.
ttlintOptional300Time in seconds for URL to be valid
v2intOptional0Use V2 of service

fileData

fileData is an array that consists of the information that you want to have stored in your media.

NameTypeDescriptionDefaultPossible Values
titleSTRINGThe title associated with the text media item.emptyempty / STRING
messageSTRINGThe media message to be included with the media item.emptySTRING
uidSTRINGThe UID of the user who created the media item.1INT
tagsSTRINGA space separated string containing words to be used as tags for the media item.emptyempty / STRING
filenameSTRINGA string that is going to be assigned as the original name of the file.emptyempty / STRING
extensionSTRING The extension that is going to be set as the original file extension of the text file.empty / STRINGpng,jpeg,mov
channelINTThe channel ID the media item is going to be uploaded into.emptyINT (channel ID)
dateYYYY-MM-DD HH:MM:SSThe date and time the media item started to be uploaded.emptyYYYY-MM-DD HH:MM:SS
urlSTRINGThe url reference.emptyempty
metadataARRAYAn ARRAY for any additional information that is to be stored with the media item. It is stored as an associated array in this field.

NB 1: You have to set the values of the metadata as an array which itself is a value of the 'users' array.

NB 2: When retrieving the information about the media using the API (via function Media.fileGetInfo), you do not specify the 'user' key: the data is returned as: metadata['synopsis'] = 'test1
empty array( 'user'=> Array ( 'synopsis' => 'test1', 'pin' => 'test2' ) )
moderationstatusINTThe initial moderation status of the media item once it is uploaded into MediaFactory.00,1,2,3,4 OR (unmoderated, accepted, denied, deleted, notdenied, moderated, all)
geo_latitudeNUMBERThe latitude of of where the media item was created. This is usually set in conjunction with Google Maps and the user plotting the pin on the map.empty62.86
geo_longitudeNUMBERThe latitude of of where the media item was created. This is usually set in conjunction with Google Maps and the user plotting the pin on the map.empty-52.44
parentidINT The media ID that is going to be assigned as the parent to this media item. This would be used in conjunction with context to create text comments.emptyINT
contextSTRINGThe type of media that is being uploaded.'generic''generic', 'all', 'comment', 'note', 'commentnote', 'genericcomment', 'parent','child'
languageSTRINGA 2-letter ISO code associated with the media.n/aSTRING
visibilitySTRINGThe visibility of the media item to the public once uploaded into MediaFactory.'VISIBLE''VISIBLE', 'HIDDEN'
groupidINT or ARRAYThe ID, or array of IDs, of the group that the media item is going to be uploaded into.

Note: To specify that the media item should _NOT_ be added to a group, set this value as 0.
empty9499
or
array(9499,9500)

Response

fileData is an array that consists of the information that you want to have stored in your media.

NameTypeDescription
resultINTThe media ID of the newly created media item in MediaFactory.

Sample Response

Code examples

0 comments

Be the first to comment on getUploadURL.

Add a Comment

  • captcha