Http error 416 Requested range not satisfiable, using Google Drive Rest API on Android
<p>Below is the piece of code. The code works correctly, except on one instance for one of the user using Samsung Tab 10.1</p>

<pre><code>String pageToken = null;
do {

    FileList remoteImageList = mService.files().list()
            .setSpaces("appDataFolder")
            .setPageToken(pageToken)
            .setQ("mimeType='image/webp'")
            .setPageSize(10)
            .setFields("nextPageToken, files(id, name)")
            .execute();
    for (com.google.api.services.drive.model.File file : remoteImageList.getFiles()) {

        File newLocalImage = new File(getExternalFilesDir(null), file.getName());
        FileOutputStream fos = new FileOutputStream(newLocalImage);
        mService.files()
                .get(file.getId())
                .executeMediaAndDownloadTo(fos);
        fos.close();

    }
    pageToken = remoteImageList.getNextPageToken();
} while (pageToken != null);
</code></pre>

<p>Below is the message in the IOException. </p>

<pre><code>416 Requested range not satisfiable
{
"error": {
"errors": [
{
    "domain": "global",
    "reason": "requestedRangeNotSatisfiable",
    "message": "Request range not satisfiable"
}
],
"code": 416,
"message": "Request range not satisfiable"
}
}
</code></pre>

<p>From the code, I can see that the error is generated when calling executeMediaAndDownloadTo method. The implementation of that method uses MediaHttpDownloader (part of Google API), and the implementation looks correct. The only thing I can think of is that the Samsung Tab 10.1 device has a different implementation of the Google API, which might have a bug?</p>

<p>Has anyone faced this issue before?</p>