Search code examples
asp.netgoogle-docs-apigoogle-drive-api

GoogleDrive downloadURL is not populating


I am trying to integrate Google-docs UI with ASP.NET Web application.

In this files are stored on our file storage and We want to open Google Docs Editor to edit the word/excel/PPT files.

As a part of POC for this requirement, I am doing below:

  1. Uploading file into Google Drive using below code:

    Dim objInsert As Google.Apis.Drive.v2.FilesResource.InsertMediaUpload = objDriveService.Files.Insert(objFile, objStream, sMimeType)
    objInsert.Convert = True
    objInsert.Upload()
    
  2. Getting response after upload and using objFile.AlternateLink property to open the Editor to edit file.

  3. I am facing the issue to download the file when I am using objInsert.Convert = True. when I am making the call to File object my Download URL (objFile.DownloadUrl) is not returning it is set with Null. If I don't use the objInsert.Convert = True then I am getting Download URL but problem is then AlternateLink open the file in View mode with various option, I want the URL to open it directly in editor.

Please suggest what am I missing here.


Solution

  • UPDATE: this was already asked here: DownloadUrl missing from metadata for file on Google Drive API

    I think it is the expected behaviour. You can't directly download a Google file type, you have to export it to some compatible format.