将Google云端硬盘文件网址转换为Google文档查看器

时间:2014-10-13 15:20:47

标签: c# google-api

我想将HTML上传到Google云端硬盘并获取网址。此代码上传很好,它返回文件的URL。但我想在Google Doc查看器中获取文件URL。我是怎么做到的?

File body = new File();
body.Title = Path.GetFileNameWithoutExtension(item);

//body.Description = "A test document";

body.MimeType = "text/html";
byte[] byteArray = System.IO.File.ReadAllBytes(item);

var stream = new MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = 
    service.Files.Insert(body, stream, "application/vnd.google-apps.document");

request.Convert = true;
request.Upload();
File file = request.ResponseBody;
var id = file.Id;

0 个答案:

没有答案
相关问题