java - Google Drive Upload with Optional Query Parameters - OCR -


about google drive, in document, google says there 3 types of uploadtype: google evidence

we have media, multipart , resumable, says in image above.

also, in same document mentioned, google give example on java, explaining how upload file google drive.

public class myclass { private static file insertfile(drive service, string title, string description,   string parentid, string mimetype, string filename) { // file's metadata. file body = new file(); body.settitle(title); body.setdescription(description); body.setmimetype(mimetype);  // set parent folder. if (parentid != null && parentid.length() > 0) {   body.setparents(       arrays.aslist(new parentreference().setid(parentid))); }  // file's content. java.io.file filecontent = new java.io.file(filename); filecontent mediacontent = new filecontent(mimetype, filecontent); try {   file file = service.files().insert(body, mediacontent).execute();    // uncomment following line print file id.   // system.out.println("file id: " + file.getid());    return file; } catch (ioexception e) {   system.out.println("an error occured: " + e);   return null; } }    // ... } 

i want set optional query parameter, explained in image. can't find how set ocr , ocrlanguage in java sdk of google drive. example of upload above, don't have parameter set, also, not clear uploadtype java example uses upload.

you can use generic set property method

file body = new file();  body.settitle(title); body.set("ocr",true); body.set("ocrlanguage", "zh"); 

Comments