将字节[]从AppEngine Java保存到Google驱动器
->为什么insert.execute()不能捕获异常。。。?什么都不做。将字节[]从AppEngine Java保存到Google驱动器,java,google-app-engine,google-drive-api,Java,Google App Engine,Google Drive Api,->为什么insert.execute()不能捕获异常。。。?什么都不做。 ->当我离开“fileItemData”时,我在google drive中得到一个项目。那么它有什么问题呢?我正在尝试上载到Google AppEngine并将其存储到AppEngine上的Google Drive。您能用较小的数据尝试一下您的代码吗,例如: byte[] fileItemData = blobstoreService.fetchData(blobKey, 0, 999999); ByteArray
->当我离开“fileItemData”时,我在google drive中得到一个项目。那么它有什么问题呢?我正在尝试上载到Google AppEngine并将其存储到AppEngine上的Google Drive。您能用较小的数据尝试一下您的代码吗,例如:
byte[] fileItemData = blobstoreService.fetchData(blobKey, 0, 999999);
ByteArrayContent mediaContent = new ByteArrayContent(fileItemMimeType, fileItemData);
insert = driveService.files().insert(body, mediaContent);
File file = insert.execute();
让我知道这是否有效…我不知道哪里出了问题-
insert.execute()
是否出现异常?当您“离开”fileItemData
时,获取项目是什么意思?如果我插入时没有fileItemData-很抱歉,我应该说mediaContent->insert=driveService.files().insert(body);<我会在google Drive中看到该条目我不会得到异常。。。使用mediacontent插入时什么也没发生。不起作用。行插入。。。只有在i.insert(body.execute()
(执行日志的下一行)而不是.insert(body,mediaContent.execute()
>(未执行日志的下一行,且引擎上没有错误日志)的情况下,后跟日志才有效。使用.insert(body).execute()
创建一个完美的没有内容的google驱动器条目。Google Drive如预期的那样说:>“很抱歉,我们无法在原始源中找到文档。>请验证文档是否仍然存在。”。我猜发生了一个未捕获的异常。您是否尝试过使用try{…}cache(异常e){//write e.getMessage()to log}来包围调用?它被以下内容包围:}catch(GoogleJsonResponseException e){}catch(HttpResponseException e){}catch(IOException e){}catch(异常e){我删除了这些触发器/**}catch(GoogleJsonResponseException e){*}catch(HttpResponseException e){*}catch(IOException e){*/并且只剩下“}catch(Exception e){”现在“Hello World”被存储到了Google驱动器中。这同样适用于我的“byte[]fileItemData=blobstoreService.fetchData(blobKey,099999);”…最后一次尝试是读取所有的catch(…我删除了…->只是为了重现问题
ByteArrayContent mediaContent = ByteArrayContent.fromString("text/plain", "Hello World")
driveService.files().insert(body, mediaContent).execute();