无需转换即可在Google文档上进行修改

时间:2016-03-25 16:45:35

标签: google-drive-api google-docs google-docs-api

我将我的系统与Google云端硬盘集成。到目前为止,一切都在运作,但有一件事。我无法编辑上传的Word文档,而无需先将其转换为Google文档。

我已经在这里阅读了使用Chrome插件的可能性: https://support.google.com/docs/answer/6055139?hl=en

但那不是我的目标。我将文件的信息存储在我的数据库中,然后我只是请求正确的URL进行编辑和预览。预览工作正常,但是当我尝试编辑URL时,它说该文件不存在。如果我转换文件(使用Google云端硬盘界面)并传递新ID,则可以使用。我不想将用户的文档转换为Google云端硬盘,因为他们仍然使用Word作为主要的编辑软件。

有没有办法实现这个目标?

这就是我现在正在做的事情:

public static File UploadFile(FileInfo fileInfo, Stream stream, string googleAccount)
{
    var mimetype = GetValidMimetype(fileInfo.MimeType);
    var parentFolder = GetParentFolder(fileInfo);
    var file = new File { Title = fileInfo.Title, MimeType = mimetype, Parents = parentFolder };
    var uploadRequest = _service.Files.Insert(file, stream, mimetype);

    uploadRequest.Upload();
    file = uploadRequest.ResponseBody;

    ShareFileWith(file.Id, googleAccount);

    return file;
}

这是用于编辑的网址(其中{0}是文件ID):

https://docs.google.com/document/d/{0}/edit?usp=drivesdk

我知道为了转换文件,我只需要:

uploadRequest.Convert = true;

但同样,那不是我想要的。有可能吗?

谢谢!

修改

只是一个更新。 Convert = true应该已经有效,但事实并非如此。我在这里https://github.com/google/google-api-dotnet-client/issues/712

提出了一个问题

Bottomline,它只适用于我在Google Docs上打开文件然后使用其ID ...

0 个答案:

没有答案