从转换后的文档中获取Google Drive api的webContentLink [英] Get webContentLink from google drive api with converted document

查看:237
本文介绍了从转换后的文档中获取Google Drive api的webContentLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用REST调用的Google云端硬盘。我想上传任何类型的文件到客户端的驱动器。我在我的web应用程序中使用了两个来自谷歌驱动器的链接,可视化和下载链接。

我从webContentLinkjson属性获得下载链接,从alternateLink链接。



有些文件如电子表格,文档和纯文本必须转换,所以我将convert参数设置为true。



问题

使用发送的文件将

转换为另一个Google文档类型,即json返回没有webContentLink属性!如何在转换文档文件时使用下载和可视化功能?

EDITED



我正在寻找在转换之前上传的原始文件的下载链接。例如,如果我上传一个xls文件,我想要有一个用于原始xls文件的下载链接。
使用exportLinks列表,我有许多xlsx链接,但我无法获得正确的,exportLinks中的mime类型与原始文件mimeType不同。对于某些文件,给出的两个电子表格exportLinks中的一个被破坏...

解决方案

您必须获取返回的JSON的 exportLinks 属性。



您将拥有其中的几个,具体取决于在文件的格式上。至少一个是所有原生格式的共同点,其中application / pdf mime类型。


I'm using Google Drive with REST calls. I want to upload any kind of file to client's drive. I use two links from google drive in my web application, the "visualization" and "download" links.

I get download link from "webContentLink" json property, and visualization link from "alternateLink".

Some files like spreadsheets, documents and plain text must be converted, so I set the "convert" parameter to "true".

The problem

with the file sent is converted to another google docs type, the json returned doesn't have the "webContentLink" property! How can I have both links download and visualization when I'm working with converted document files?

EDITED

I'm looking for the download link for the original file uploaded before it's converted. If I upload an xls for example, I would like to have a download link for the original xls file. With "exportLinks" list, I have a bunch of links for xlsx, but I have no way to get "the right one", the mime types in "exportLinks" are different from the original file mimeType. And for some files, one of the two spreadsheet exportLinks given is broken...

解决方案

If you want download links for google native documents, you have to fetch the exportLinks properties of the JSON returned.

You will have several of them, depending on the format of the file. One at least is common to all native format, the one with "application/pdf" mime type.

这篇关于从转换后的文档中获取Google Drive api的webContentLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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