2

i am trying to upload file in GoogleDrive with setConvert(true); my code is as follows:

InputStreamContent mediaContent = new InputStreamContent(mimeType, new BufferedInputStream(new FileInputStream(filename)));
mediaContent.setLength(filename.length());
Insert insert = service.files().insert(body, mediaContent);
insert.setConvert(true);        
insert.getMediaHttpUploader().setDirectUploadEnabled(false);
insert.getMediaHttpUploader().setProgressListener(new FileUploadProgressListener());
file = insert.execute();

its giving me below error

IOException: com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error { "code": 500, "errors": [ { "domain": "global", "message": "Internal Error", "reason": "internalError"
} ], "message": "Internal Error" }

  • What's on the body? Does it work without conversion is set to true? I'm not able to reproduce your problem. – Burcu Dogan Apr 15 '13 at 09:48
  • body is a com.google.api.service.drive.model.File type variable, which contain metadata about the file like title, description, mimetype etc.Its working fine without using setConvert(true), but if i am not using this than file.getExportLinks().get(PDF_FILE_TYPE); is returning NULL, and without PDF download URL i can't download the PDF of the inserted File. – Purnendu Mishra Apr 15 '13 at 12:24
  • 1
    If it's an unconvertible mimeType, there may be no export links. What's your mime-type? – Burcu Dogan Apr 15 '13 at 14:58
  • mime-type is application/vnd.openxmlformats-officedocument.wordprocessingml.document or application/vnd.openxmlformats-officedocument.spreadsheetml.sheet or application/vnd.openxmlformats-officedocument.presentationml.presentation, i am not using unconvertible mime type because the earlier code is working fine for small size files, but for big size files it was giving error as i asked on [this link](http://stackoverflow.com/questions/15970423/uploading-downloading-of-large-size-file-to-google-drive-giving-error). – Purnendu Mishra Apr 16 '13 at 04:35
  • Conversion is an async process I guess and the conversion is probably not completed when upload is done. Let me check back with the team... – Burcu Dogan Apr 16 '13 at 14:43

0 Answers0