gpt4 book ai didi

java - 无法通过 java api 将图像文件上传到 Google Doc

转载 作者:行者123 更新时间:2023-11-29 06:00:50 24 4
gpt4 key购买 nike

下面是我的代码

DocsService client = new DocsService("testappv1");
client.setUserCredentials(username, password);
client.setProtocolVersion(DocsService.Versions.V2);
File file = new File("C:/test.jpg");
DocumentEntry newDocument = new DocumentEntry();
newDocument.setTitle(new PlainTextConstruct("test"));
String mimeType = DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
newDocument.setMediaSource(new MediaFileSource(file, mimeType));
newDocument = client.insert(destFolderUrl, newDocument);

文档创建成功,但未包含任何内容。

最佳答案

尝试以下操作

client.insert(new URL("https://docs.google.com/feeds/documents/private/full/?convert=false"), newDocument);

我认为 ?convert=false 位很重要,不知道在没有 url 的情况下你是怎么做到的

client.insert(new URL(destFolderUrl+ "?convert=false"), newDocument);

希望对你有用

关于java - 无法通过 java api 将图像文件上传到 Google Doc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10170579/

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