java - 驱动 Api 电话

标签 java android iphone google-drive-api

我正在尝试创建一个 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/

相关文章:

Android CMake 构建默认添加 no-exceptions 和 no-rtti

iPhone UITableViewCell 图层阴影

java - 如何在现有的Java应用程序中做到模块化?

java - Hibernate注释@Query参数无法正常工作

java - NoSuchElementException : No line found when getting user input with scanner?

android - 如何从 asp.net web 服务检索 base64 字符串到 android

java - 使用Java中的Kinect数据集计算两条线(代表人的 ARM )之间的角度

android - Flutter 应用程序在 Android 上启动时崩溃

iphone - 在opengl es中画一条白线

iphone - UI 滞后,背景频繁更新