Video upload to rackspace fails with image cannot be displayed

Go To StackoverFlow.com

1

So i did a custom media upload service for tweetbot. Images upload just fine, URL returned and posted by tweetbot. However when i try to upload a video, it does retrieve the URL but this happens :

http://c0728267.cdn2.cloudfiles.rackspacecloud.com/1333560894-movie.mp4

Notice the image in front of the text on the top? It's a video however. What am i doing wrong?

Here is the code for the upload process

$oauthecho = new TwitterOAuthEcho();
$oauthecho->userAgent = 'dpkgme test app';
$oauthecho->setCredentialsFromRequestHeaders();

if ($oauthecho->verify()) {      

 // Verification was a success, we should be able to access the user's Twitter info from the responseText.
 $userInfo = json_decode($oauthecho->responseText, true);
 $twitterId = isset($userInfo['id']) ? $userInfo['id'] : null;


                    $tweet = $_POST['message'];

                    error_reporting(E_ALL);
                    ini_set('display_errors', 1);

                    // include the API
                    require("cloudfiles.php") ;

                    // cloud info
                    $username = ''; // username
                    $key ='' ; // api key
                    $container = ''; // container name

                    ob_start();


                    $localfile = $_FILES['media']['tmp_name'];
                    $filename = $_FILES['media']['name'];
                    $nf = time().'-'.$filename; 


                    ob_flush();

                    // Connect to Rackspace
                    $auth = new CF_Authentication($username, $key);
                    $auth->authenticate();
                    $conn = new CF_Connection($auth);

                    // Get the container we want to use
                    $container = $conn->create_container($container);

                    // store file information

                    ob_flush();

                    // upload file to Rackspace
                    $object = $container->create_object($nf);
                    $object->load_from_filename($localfile);

                    $uri = $container->make_public();
                    //print "Your URL is: " . $object->public_uri();

                    $imagePageUrl = $object->public_uri();


                    ob_end_flush();


$link = 'http://c0728267.cdn2.cloudfiles.rackspacecloud.com/'.$nf ; 

$shortenedurl = file_get_contents('http://gl.gy/index.php?url='.$link);
$keys = parse_url($shortenedurl); // parse the url
    $path = explode("/", $keys['path']); // splitting the path
    $last = end($path); // get the value of the last element 


    echo '<mediaurl>http://gl.gy/'.$last.'</mediaurl>';
2012-04-04 17:58
by NoName


0

Solved. I added content type detection. It is working fine now.

2012-04-05 18:05
by NoName
Ads