gpt4 book ai didi

java - 谷歌驱动器 SDK 上传演示文稿时出错

转载 作者:行者123 更新时间:2023-12-01 05:02:11 25 4
gpt4 key购买 nike

我正在尝试使用 google api 驱动器上传演示文稿,但演示文稿不完整,一些幻灯片是空白的,查看日志,这就是显示的内容

com.google.api.client.http.HttpRequest execute: -------------- REQUEST  --------------
PUT https://www.googleapis.com/upload/drive/v2/files? uploadType=resumable&upload_id=AEnB2UrDPJgLIehcqH--aWgwl- R_atDhqdvbXnJiWMXKE0V0euJGOvULbM4y5YmvUePWaHSrYyFdOgsmTASJGe-Dtvg09NCkzQ
Accept-Encoding: gzip
Authorization: Bearer ya29.AHES6ZTfSaK77NGCcZO1bK_aTbT8zVX3eslOAb8BkrvpeXARK94XsXY
Content-Range: bytes 0-1048575/6774302
User-Agent: Google-HTTP-Java-Client/1.11.0-beta (gzip)
Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation
Content-Length: 1048576

com.google.api.client.http.HttpRequest execute: curl -v --compressed -X PUT -H 'Accept- Encoding: gzip' -H 'Authorization: Bearer ya29.AHES6ZTfSaK77NGCcZO1bK_aTbT8zVX3eslOAb8BkrvpeXARK94XsXY' -H 'Content-Range: bytes 0- 1048575/6774302' -H 'User-Agent: Google-HTTP-Java-Client/1.11.0-beta (gzip)' -H 'Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation' -d '@-' -- https://www.googleapis.com/upload/drive/v2/files? uploadType=resumable&upload_id=AEnB2UrDPJgLIehcqH--aWgwl- R_atDhqdvbXnJiWMXKE0V0euJGOvULbM4y5YmvUePWaHSrYyFdOgsmTASJGe-Dtvg09NCkzQ << $$$

com.google.api.client.http.HttpResponse <init>: -------------- RESPONSE --------------
308 OK
server: HTTP Upload Server Built on Oct 3 2012 16:52:30 (1349308350)
range: bytes=0-1048575
x-range-md5: 19230c1c1a0fc493f3431f46cf30c14c
date: Mon, 05 Nov 2012 22:00:33 GMT
pragma: no-cache
expires: Fri, 01 Jan 1990 00:00:00 GMT
cache-control: no-cache, no-store, must-revalidate
content-length: 0
content-type: text/html; charset=UTF-8
x-google-cache-control: remote-fetch
via: HTTP/1.1 GWA

这是正在使用的代码:

byte[] myFile = readImageData(blobKey,size);
ByteArrayContent mediaContent = new ByteArrayContent(mimeType, myFile);

Drive.Files.Insert insert = service.files().insert(body, mediaContent);
insert.getMediaHttpUploader().setChunkSize(1024 * 1024);
File file = insert.execute();

更新

做了一些测试,似乎只有在上传扩展名为.pptx的演示文稿时才会出现错误

该扩展名的 mimeType 有问题吗?

我希望有人能帮助我,谢谢。

最佳答案

看起来像resumable upload protocol没有得到正确实现。 308 响应代码表示仅上传了一部分请求,您应该继续处理下一个 block 。

如果从代码中删除以下行,它是否可以正常工作?

insert.getMediaHttpUploader().setChunkSize(1024 * 1024);

关于java - 谷歌驱动器 SDK 上传演示文稿时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13241356/

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