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: 
OK. I got it.

Files uploads successfully with **Content-Type == "application/octet-stream"**. Looks like bug on GoogleDrive side with mime-type'd files.
In this scenario my raw files (DNG, CR2, NEF etc.) stores in GoogleDrive with incorrect mime-type (as a result there is no preview for these files).

So i can't filter files by mime-type anymore.

```
Query string = (mimeType = 'image/x-adobe-dng' or mimeType = 'image/x-canon-cr2' or mimeType = 'image/x-nikon-nef').

```

I tried to filter files by keyword title, but looks like titles doesn't contain extension, but in response item titles contain extension.

```
Query string = (title contains '.dng' or title contains '.cr2' or title contains '.nef').

```

So i have to filter my files not by mime-type or by title, but by fullText keyword.

```
Query string = (fullText contains '.dng' or fullText contains '.cr2' or fullText contains '.nef').

```

Conclusion: 

1. GoogleDrive uploader checks **Content-Type**, even if convert option is set to **false**.
2. GoogleDrive fails from time to time with this **convertation**.
3. Uploader works fine with **Content-Type == 'application/octet-stream'**.
4. GoogleDrive query string keyword **title doesn't contain file extension**, but in response titles have extension.
5. GoogleDrive query string keyword **fullText contains filename with extension** (mb its not very fast for text files).
6. To test your request you can use this tool <https://developers.google.com/drive/v2/reference/files/list> in the end of page.
7. GoogleDrive API crashes from time to time with HTTP status **500 Internal Server Error**:

`{"error":{"errors":[{"domain":"global","reason":"backendError","message":"Backend Error"}],"code": 500,"message": "Backend Error"}}`
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.