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