Video upload to rackspace fails with image cannot be displayed

Go To


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 :

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';

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'];

                    ini_set('display_errors', 1);

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

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


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


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

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

                    // store file information


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

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

                    $imagePageUrl = $object->public_uri();


$link = ''.$nf ; 

$shortenedurl = file_get_contents(''.$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>'.$last.'</mediaurl>';
2012-04-04 17:58
by NoName


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

2012-04-05 18:05
by NoName