【发布时间】:2014-01-31 10:16:11
【问题描述】:
我正在使用Quickstart: Run a Drive app in JavaScript 教程将文档上传到谷歌驱动器。我能够成功运行 HTML 文件并上传文档。
例如我上传了一个 test.docx 文件,并且 JSON 响应在帖子的末尾
问题是,备用链接仅以视图(类似 pdf)模式打开文档。 对于这个例子,这里是链接 https://docs.google.com/a/easytha.com/file/d/0B7x-2AmDcIyRN3hPVVRWSUhQaWs/edit
但是我如何构建一个 URL 以便它像这样在编辑模式下打开 https://docs.google.com/a/easytha.com/document/d/1rH79lwfX4bZ4R5EEhSaTy52dfdKiezNOaaR-6ORBcoI/edit
而且这两个是同一个文件。
alternateLink
"https://docs.google.com...hQaWs/edit?usp=drivesdk"
appDataContents
false
copyable
true
createdDate
"2014-01-31T10:01:31.092Z"
downloadUrl
"https://doc-00-10-docs....4259&e=download&gd=true"
editable
true
etag
""GJcqFgACxaboeo6aKKeP6-mh0PE/MTM5MTE2MjQ5MDg1NQ""
fileExtension
"docx"
fileSize
"12497"
iconLink
"https://ssl.gstatic.com...s/icon_10_word_list.png"
id
"0B7x-2AmDcIyRN3hPVVRWSUhQaWs"
kind
"drive#file"
labels
Object { starred=false, hidden=false, trashed=false, more...}
lastModifyingUser
Object { kind="drive#user", displayName="sapan parikh", isAuthenticatedUser=true, more...}
lastModifyingUserName
"sapan parikh"
lastViewedByMeDate
"2014-01-31T10:01:30.855Z"
md5Checksum
"0acf21000754601319600c5182d794d4"
mimeType
"application/vnd.openxml...rdprocessingml.document"
modifiedByMeDate
"2014-01-31T10:01:30.855Z"
modifiedDate
"2014-01-31T10:01:30.855Z"
originalFilename
"test.docx"
ownerNames
["sapan parikh"]
owners
[Object { kind="drive#user", displayName="sapan parikh", isAuthenticatedUser=true, more...}]
parents
[Object { kind="drive#parentReference", id="0ALx-2AmDcIyRUk9PVA", selfLink="https://content.googlea...nts/0ALx-2AmDcIyRUk9PVA", more...}]
quotaBytesUsed
"12497"
selfLink
"https://content.googlea...2AmDcIyRN3hPVVRWSUhQaWs"
shared
false
title
"test.docx"
userPermission
Object { kind="drive#permission", etag=""GJcqFgACxaboeo6aKKeP6-...XMO0VKCtlQA-JDZdgem3VQ"", id="me", more...}
webContentLink
"https://docs.google.com...SUhQaWs&export=download"
writersCanShare
true
【问题讨论】:
-
我也遇到过这个问题。问题是谷歌驱动器只能编辑谷歌驱动器文档。因此,当您上传 docx 文件时,它会创建一个新的 google drive doc 并在您想要编辑它时将您重定向到此文件。这意味着它是一个不同的文件。我不确定 javascript api,但在 C# 中有一个选项可以在上传时转换文档。
-
你是对的 convert:true 参数成功了。您想将您的评论转换为答案吗?
-
欢迎您,我将添加它作为答案。我将其发布为评论,因为我不确定这是否是解决方案。
标签: javascript google-drive-api google-docs-api