简体   繁体   English

使用Drive v2 Java API将CSV上传到Google云端硬盘电子表格

[英]Upload CSV to Google Drive Spreadsheet using Drive v2 Java API

I am trying to upload a CSV as a Google spreadsheet 我正在尝试将CS​​V上传为Google电子表格

I do see that there is a request parameter convert=true available at 我确实看到有一个请求参数convert = true available at

Google Developer - insert. Google开发者 - 插入。

Can some one help me on how to set this flag in Java API? 有人可以帮助我如何在Java API中设置此标志吗?

The Drive.Files.Insert class has a setConvert method that you can use before calling execute . Drive.Files.Insert类有一个setConvert方法,您可以在调用execute之前使用该方法。 Using the file.insert sample as reference, you have to replace the following line: 使用file.insert示例作为参考,您必须替换以下行:

File file = service.files().insert(body, mediaContent).execute();

with: 有:

File file = service.files().insert(body, mediaContent).setConvert(true).execute();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java Drive Rest V2 API从Google Drive获取文档和文件的绝对路径? - How to get absolute path of a document and file from Google Drive Using Java Drive Rest V2 API? 如何上传带有链接的文件到Google Drive REST API v2 - How to upload a file with a link to Google Drive REST API v2 Google Drive Java API V2与V3 - Google Drive Java API V2 vs V3 使用 Java 和 Google Drive API V3 将文件上传到共享的 Google Drive 位置? - Upload a file to shared google drive location using Java with Google Drive API V3? 使用Google Spreadsheet API在Google中的Google驱动器中创建电子表格 - Create Spreadsheet using Google Spreadsheet API in Google drive in Java 使用java api将文件上传到谷歌驱动器 - upload file into google drive using java api java google drive api V3 多部分和可恢复上传 - java google drive api V3 MultiPart & Resumable Upload Java:无法使用Google Drive API下载电子表格 - Java :Not able to download spreadsheet using google drive API 如何使用 Google Drive Java API v3 复制 Google Drive 上的文件? - How do I copy a file on a Google Drive using v3 of the Google Drive Java API? 如何使用Java API在Google驱动器中上传Excel工作表 - how to upload an excel sheet in google drive using java api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM