gpt4 book ai didi

java - 驱动 Api 电话

转载 作者:行者123 更新时间:2023-11-29 21:45:07 27 4
gpt4 key购买 nike

我正在尝试创建一个 java 程序,它将创建 excel 文件并将其上传到谷歌驱动器中。上传后我需要它来授予权限。我已经完成了所有这些,但问题在于尝试将 excel 文件转换为 google 文件,以便使用表格的人能够使用手机更新它们。我无法在 google api 上找到有关如何执行此操作的任何帮助。任何帮助将不胜感激。

最佳答案

假设您有 Excel 文件的路径:

java.io.File fileContent = new java.io.File(excelfilepath);
FileContent mediaContent = new FileContent("application/vnd.ms-excel", fileContent);

// File's metadata.
File body = new File();
body.setTitle(fileContent.getName());
body.setMimeType("application/vnd.ms-excel");

// THIS IS THE IMPORTANT PART
Insert request = service.files().insert(body, mediaContent);
request.setConvert(true);
File file = request.execute();
// END OF THE IMPORTANT PART

if (file != null) {
showToast("Data Uploaded: " + file.getTitle());
}

关于java - 驱动 Api 电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16073701/

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