通过Google云端硬盘REST API上传或创建包含内容的新文件? [英] Upload or create new file with content via Google Drive REST API?

查看:342
本文介绍了通过Google云端硬盘REST API上传或创建包含内容的新文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Google Drive REST API创建基于模板的新文档(我没有使用Java或JS SDK)。



我想创建基于文字处理模板的文档,可以从Drive下载模板并替换一些内容$关键字,或者编辑rtf格式模板并将其作为新文件插入。



我对REST很满意,我可以从Drive下载模板,并访问exportLinks将文件内容下载为rtf或txt。但是......一旦我编辑了内容,如何将内容作为fileContent提供给insert / update http post?



这可能吗?我认为这是通过该方法:

POST https://www.googleapis.com/upload/drive/v2/files



谢谢!

解决方案

是的,这是可能的。查看此文档: https://developers.google.com/drive/manage-uploads 您可以使用简单的媒体上传或分段上传,每个上传都在上面的链接中有详细记录。



仅供参考,如果您已经有一个文件,而您只想要要替换它的数据,您还需要查看 Files.update 。您上传的方式与上述文档相同。


I'm trying to create a new document based on a template through the Google Drive REST API (I'm not using the Java or JS SDKs).

I'd like to create the document based on a word-processing template, either by downloading the template from Drive and replacing some content $keywords, or, editing an rtf format template and inserting that as a new file.

I'm comfortable with REST and I'm able to download the template from Drive, and access the exportLinks to download the file content as rtf or txt. But... once I've edited the content, how to I provide that content as fileContent to the insert/update http post?

Is this possible? I thought it would be through the method:

POST https://www.googleapis.com/upload/drive/v2/files

Thanks!

解决方案

Yes, it is possible. Take a look at this documentation: https://developers.google.com/drive/manage-uploads You can use simple media upload or multipart upload each of which are well documented in the link above.

FYI, if you already have a file and you just want to replace the data of it, you would also want to take a look at Files.update. The way you upload is same as the documentation above.

这篇关于通过Google云端硬盘REST API上传或创建包含内容的新文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆