1

When I am uploading files, sometimes it will stick on a large file for much longer than it is supposed to. It uploads the previous files ok, but it always gets stuck at this 26MB file. The upload should only take 3 minutes, but it runs for 3+ hours, uses maximum upload bandwidth in Task Manager, and errors with 403 Unauthorized or 'java.io.IOException: unexpected end of stream' - just random errors. I'm uploading to a Google service account using a private key. I'm using Google Eclipse plugin, and added Drive API via Eclipse plugin. The only thing I can think of is to run it through Fiddler2/4 proxy to troubleshoot, but I shouldn't have to do that.

Code

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
        System.out.println("type of file "+f.getName()+":"+type + ", length:"+f.length());
        File driveFile = DriveService.insertFile(name, type, Constants.DOC_TYPE_PRIMARY, bis);

public static File insertFile(String name, String type, String docType, InputStream inputStream) throws IOException, Exception
{
    File file = new File();
    file.setTitle(name);
    file.setMimeType(type);
    file.setDescription(docType);

    List<ParentReference> parents = new ArrayList<ParentReference>(); //create parent ref
    parents.add(new ParentReference().setId(Constants.DRIVE_FOLDER_IDS.get(docType)));
    file.setParents(parents);

    InputStreamContent isc = new InputStreamContent(type, inputStream);
    File retval = getService().files().insert(file, isc).execute();

    //apply domain reader access
    enableDomainReaderAccess(retval.getId());

    return retval;
}

Log

type of file MWV Soda Packaging Report_First Draft.pptx:null, length:26373917

More Errors

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
  "code" : 500,
  "errors" : [ {
    "domain" : "global",
    "message" : "Internal Error",
    "reason" : "internalError"
  } ],
  "message" : "Internal Error"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:423)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.mwv.pic.service.DriveService.insertFile(DriveService.java:167)



type of file Report Soda.ppt:application/vnd.openxmlformats-officedocument.presentationml.presentation, length:9103360
Exception in thread "main" java.io.IOException: insufficient data written
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.close(HttpURLConnection.java:3213)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:81)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:964)
at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequest(MediaHttpUploader.java:559)
at com.google.api.client.googleapis.media.MediaHttpUploader.resumableUpload(MediaHttpUploader.java:434)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:345)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:418)

Version

google-api-services-drive-v2-rev107-1.16.0-rc.jar

Chloe
  • 25,162
  • 40
  • 190
  • 357
  • check this it might be the same problem http://stackoverflow.com/questions/19769000/google-drive-uploading-file-size-limit/20095723#20095723 – Linda Lawton - DaImTo Dec 09 '13 at 13:10
  • @DaImTo Naa, that's not it. It sticks on one file in particular for a long time and doesn't do much then it throws an error. There is no rapid succession of files. I've tried several times and got the same result, on same file. It is not loading the server hardly at all, as my connection is not fast. It works on a co-workers system, different network. – Chloe Dec 10 '13 at 03:18
  • 500 error is a general server error i get it in google analytics when the server is just busy. Have you tried adding the Implementing exponential backoff? https://developers.google.com/drive/handle-errors#implementing_exponential_backoff I added that and it worked for me by the time my code gets to 7 its normaly up and running again. – Linda Lawton - DaImTo Dec 10 '13 at 08:03
  • How can I implement exponential backoff? It's only one file. It takes 3 hours to fail, yet it uses bandwidth. I've tried it at all hours of the day and night. An exponential wait would be 6 hours, then 12 hours, then a whole day! That's just crazy! – Chloe Dec 10 '13 at 17:48
  • You dont need to wait that long to try again. – Linda Lawton - DaImTo Dec 11 '13 at 08:01

0 Answers0