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.
fileData is an array that consists of the information that you want to have stored in your media.
Name
Type
Description
Default
Possible Values
title
STRING
The title associated with the text media item.
empty
empty / STRING
message
STRING
The media message to be included with the media item.
empty
STRING
uid
STRING
The UID of the user who created the media item.
1
INT
tags
STRING
A space separated string containing words to be used as tags for the media item.
empty
empty / STRING
filename
STRING
A string that is going to be assigned as the original name of the file.
empty
empty / STRING
extension
STRING
The extension that is going to be set as the original file extension of the text file.
empty / STRING
png,jpeg,mov
channel
INT
The channel ID the media item is going to be uploaded into.
empty
INT (channel ID)
date
YYYY-MM-DD HH:MM:SS
The date and time the media item started to be uploaded.
empty
YYYY-MM-DD HH:MM:SS
url
STRING
The url reference.
empty
empty
metadata
ARRAY
An 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
The visibility of the media item to the public once uploaded into MediaFactory.
'VISIBLE'
'VISIBLE', 'HIDDEN'
groupid
INT or ARRAY
The 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.
empty
9499 or array(9499,9500)
Response
fileData is an array that consists of the information that you want to have stored in your media.
Name
Type
Description
result
INT
The media ID of the newly created media item in MediaFactory.
Sample Response
Code examples
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'media.getUploadURL',
'vhost' => '2',
'fileData' => $fileData,
'ttl' => $ttl,
'v2' => $v2,
'recaptchaToken' => $recaptchaToken
);
// http_build_query basically turns an array into a url-encoded list of variables
$url = $path .'?' . http_build_query($arguments,null,'&');
// get the contents from the specified url
$data = file_get_contents($url);
// transform it back into php data structures
$data = unserialize($data);
// the actual data is stored in $data['result']
print_r($data['result']);
// Include the client
require_once 'XML/RPC.php';
// Create the XMLRPC Client
$client = new XML_RPC_Client('/services/xmlrpc?APIKEY={YOURAPIKEY}', 'api.newspark.ca');
// PEAR's XML-RPC client requires all arguments to wrapped in a special value class
// XML_RPC_encode converts this automatically
$arguments = array(
XML_RPC_encode('2'),
XML_RPC_encode($fileData),
XML_RPC_encode($ttl),
XML_RPC_encode($v2),
XML_RPC_encode($recaptchaToken)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('media.getUploadURL',$arguments);
// Sending the message to the server
$response = $client->send($message);
// We also need to decode the response back to normal PHP types
$response = XML_RPC_decode($response);
print_r($response);
/*
* In ActionScript 2 remote service calls are done using the RemotingConnector Component.
* An instance of the component must exist on the stage and have an instance name.
*
* Results and Faults are handled by addEventListener's and the call parameters are placed inside of an associative array
*
* You must also specify the service class and method names under the appropriate property fields of the component
*/
var gatewayURL:String = "/services/amf2";
//Set up service call
myRemConn_rc.gatewayUrl = gatewayURL;
myRemConn_rc.serviceName = "media";
myRemConn_rc.methodName = "getUploadURL";
myRemConn_rc.params = {2:vhost, fileData:fileData, ttl:ttl, v2:v2, recaptchaToken:recaptchaToken};
myRemConn_rc.addEventListener("result", widgetResult);
myRemConn_rc.addEventListener("status", widgetFault);
//Make the call
myRemConn_rc.trigger();
/*
* Handles service result.
*/
function widgetResult(ev:Object){
//Do stuff
//Data is returned inside of ev.target.results
//(i.e. ev.traget.results.description or ev.traget.results.settings.color)
}
/*
* Handles service fault.
*/
function widgetFault(ev:Object){
//Display Error
trace("Categories Error - " + ev.code + " - " + ev.data.faultstring);
}
/*
* In ActionScript 3 remote service calls are done using the NetConnection Object.
* A Responder Object controls what functions handle successful or failed calls
* and any parameters for the call are placed in an array and passed as a parameter
* in the NetConnection.call() method.
*/
var gatewayURL:String = "/services/amf2";
var parameters:Array = new Array(vhost, fileData, ttl, v2, recaptchaToken);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("media.getUploadURL", new Responder(widgetResult, widgetFault), parameters);
/*
* Handles service result.
*/
function widgetResult(ev:Object):void{
//Do stuff
//Data is returned inside of ev
//(i.e. ev.description or ev.settings.color)
}
/*
* Handles service fault.
*/
function widgetFault(ev:Object):void{
//Display Error
error.showError(parentClip, ev.code + " - " + ev.description, "Please refresh your browser to try again.");
error.x = (parentClip.width - error.width) / 2;
error.y = (parentClip.height - error.height) / 2;
}
<%@ Page Language="vb" %>
<%
' REST gateway
dim gateway as string = "http://api.newspark.ca/services/rest/"
' Service + method we're calling.
dim method as string = "media/getUploadURL"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&vhost=2" & "&fileData=" & fileData
' HTTP Client
dim wcHTTPScrape as new System.net.WebClient()
' Opening a stream
dim objInput as System.IO.Stream = wcHTTPScrape.OpenRead(url)
dim objReader as new System.IO.StreamReader ( objInput )
' Reading the entire HTTP response and output it
Response.Write ( objReader.ReadToEnd () )
objReader.Close ()
objInput.Close ()
%>