Question: i'm creating a link sharing that on bind() events of a specific textarea ( where i paste links ) it does an `$.post` ajax callback with a preview (in case of youtube or vimeo link).
Basically, i would remove link into textarea each times that link is detected and preview is gotten.

this is the function that does the callback :

```
    $('#writer').bind('change keypress keyup keydown',function() {

   var value_= $('#writer').val();
            $('#thumb-temp').hide();

            $.post( 'checklink.php?', { string : value_ }, 
            function(response) {
                $('.writer').prepend(response);
                $('#thumb-temp').show();

    }).fail(function() { alert( "error" ) })
});

```

and the page **checklink.php** that should remove the link

```
<?
    $link = $_POST['string'];

            $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
            preg_match($reg_exUrl, $link, $url);

            $link = $url[0];
?>
<script>clearTextarea('<? echo $link ?>')</script>

```

and in the end the clearTextarea() function

```
function clearTextarea(url) {
var _textarea = $('#writer');
var _curVal     =   _textarea.val();
        var _curUrl =   url;
        var _regex      =   new RegExp( _curUrl , 'g' );
        var _newVal     =   _curVal.replace( _regex , '' );

        _textarea.val( _newVal );
}

```

Now, apparentely, this should works but nothing happens, any ideas ? I do not understand where I'm wrong :(

Answer: 
I think this would be related to raw photo files, because DRIVE tries to [convert them to JPG](http://www.photographybay.com/2013/09/26/google-goes-raw-better-conversion-now-supports-over-70-cameras-look-out-adobe/) as is done in Google+, unless you specify convert=false. You should specify in your upload API to not convert that files.

This second post says that it will allow you to preview the file [up to 25MB](https://support.google.com/drive/answer/2423485?hl=en), this size limitation could be related with your troubles. Maybe you could try to upload another photo with less than that size to ensure it's not this the limitation.
I have also seen this 500 error with google analytics a few times and its normaly due to the fact that the server is busy. If I wait a bit and try again it works. Try reading this <https://developers.google.com/drive/handle-errors#implementing_exponential_backoff> This worked form me with Google Analtyics API, normaly by the time it gets to step 6 its got access again. Haven't tried it with google Drive, but then i havent tried to upload a 25m file before. But i'm betting thats your problem.