我需要使用 Google Drive API v3 将 .doc 或 .docx 文件上传到 google Drive,然后也使用 Google Drive API v3 进行转换,以便文件的内容在我自己的 Web 应用程序(托管在 Node.js 中)中可读和可编辑。 js)。我尝试使用drive.files.copy执行此操作,但是,我不断收到错误:API返回错误:错误:不支持将上传的内容转换为请求的输出类型。谁能帮我弄清楚如何做到这一点?任何帮助将不胜感激。谢谢你!
这是我用于转换的代码,但是它不起作用:
drive.files.list({
q: "mimeType = 'application/msword'"
pageSize: 100,
fields: 'nextPageToken, files(id, name)',
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
const files = res.data.files;
if (files.length) {
console.log('Files:');
files.map((file) => {
let result = (file.name).substring(0, (file.name).indexOf('.'));
console.log(file);
console.log(`${file.name} (${file.id})`);
drive.files.copy(
{
fileId: file.id,
requestBody: {
name: result,
mimeType: 'application/vnd.google-apps.document'
} …Run Code Online (Sandbox Code Playgroud)