gpt4 book ai didi

java - 带有可选查询参数的 Google 云端硬盘上传 - OCR

转载 作者:太空宇宙 更新时间:2023-11-04 13:39:38 24 4
gpt4 key购买 nike

关于 Google 云端硬盘,在此 Document ,Google 表示有 3 种 uploadType: google evidence

我们有mediamultipartresumable,如上图所示。

此外,在提到的同一文档中,Google 给出了一个 Java 示例,解释了如何将文件上传到 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 the 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 the following line to print the File ID.
// System.out.println("File ID: " + file.getId());

return file;
} catch (IOException e) {
System.out.println("An error occured: " + e);
return null;
}
}

// ...
}

我想设置一个可选查询参数,如图所示。我找不到如何在 Google Drive 的 java SDK 中设置 ocrocrLanguage。上面的上传示例,没有设置这个参数,也不清楚这个java示例使用什么uploadType来上传。

最佳答案

您可以使用通用设置属性方法

File body = new File(); 
body.setTitle(title);
body.set("ocr",true);
body.set("ocrLanguage", "zh");

关于java - 带有可选查询参数的 Google 云端硬盘上传 - OCR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31348372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com