2

Similar to this question Getting public URL to file in Google Drive using .NET API.

using the Google.APIs.Drive.v2 API I am able to list the files DriveService.Files.List(). That returns a collection of Files.

The items have a property exportLinks, however that property is empty for all my files.

Please advise. Thanks.

Note: the folders where the files are in, are shared using Visible with Link.

Update: adding one of the resulting entries per Claudio's request:

   {
  "kind": "drive#file",
    "id": "0B3huP1kT5Jg7ckIwM1JFODhqQnM",
    "etag": "\"-tJAWr_lbRQU2o8gZ0X7BCBIlVk/MTM0MTA3MDYwODUxOQ\"",
    "selfLink": "https://www.googleapis.com/drive/v2/files/0B3huP1kT5Jg7ckIwM1JFODhqQnM",
    "alternateLink": "https://docs.google.com/file/d/0B3huP1kT5Jg7ckIwM1JFODhqQnM/edit",
    "thumbnailLink": "https://lh4.googleusercontent.com/DLv5EK327dWfKyE4OHVvqmtPNAJBh564NHWoMo_xNzjdsG9cyYgYPpca3K5VdmHfqQ=s220",
    "permissionsLink": "https://www.googleapis.com/drive/v2/files/0B3huP1kT5Jg7ckIwM1JFODhqQnM/permissions",
    "title": "WILDCHIL-BLAVEC-FULL-001.png",
    "mimeType": "image/png",
    "labels": {
     "starred": false,
     "hidden": false,
     "trashed": false,
     "restricted": false,
     "viewed": false
    },
    "createdDate": "2012-06-30T15:36:48.519Z",
    "modifiedDate": "2012-06-30T15:36:48.519Z",
    "modifiedByMeDate": "2012-06-30T15:36:46.095Z",
    "parents": [
     {
      "kind": "drive#parentReference",
      "id": "0B3huP1kT5Jg7MjNfMHZLcEdVbHM",
      "selfLink": "https://www.googleapis.com/drive/v2/files/0B3huP1kT5Jg7ckIwM1JFODhqQnM/parents/0B3huP1kT5Jg7MjNfMHZLcEdVbHM",
      "parentLink": "https://www.googleapis.com/drive/v2/files/0B3huP1kT5Jg7MjNfMHZLcEdVbHM",
      "isRoot": false
     }
    ],
    "downloadUrl": "https://doc-10-94-docs.googleusercontent.com/docs/securesc/aarkh960uprlp23t4c9u2f081smlqd2o/noa9bibpnrmajuo2632hl6ocidpf1q0j/1342476000000/03524686860055462013/03524686860055462013/0B3huP1kT5Jg7ckIwM1JFODhqQnM?h=16653014193614665626&e=download&gd=true",
    "userPermission": {
     "kind": "drive#permission",
     "etag": "\"-tJAWr_lbRQU2o8gZ0X7BCBIlVk/9STkNeCmz61YXorH3hoJimnEgfM\"",
     "id": "current",
     "role": "owner",
     "type": "user"
    },
    "originalFilename": "WILDCHIL-BLAVEC-FULL-001.png",
    "fileExtension": "png",
    "md5Checksum": "ebfa9523688cc5e0aee4cce74c288819",
    "fileSize": "701686",
    "quotaBytesUsed": "701686",
    "ownerNames": [
     "Swcatalog-canada"
    ],
    "lastModifyingUserName": "Swcatalog-canada",
    "editable": true,
    "writersCanShare": true
   },
Community
  • 1
  • 1
rufo
  • 5,158
  • 2
  • 36
  • 47
  • Please try the same request with OAuth Playground (https://code.google.com/oauthplayground) so that we can exclude issues with the client library – Claudio Cherubino Jul 16 '12 at 23:02
  • done. "exportLinks" is not included in the resulting json set. I am using this request link: https://www.googleapis.com/drive/v2/files. Note: let me know what other information you need. Thanks. – rufo Jul 17 '12 at 00:01
  • What types of files are those? Drive only provides export links for those documents it can actually export to different formats, for instance from Google Document to plain text – Claudio Cherubino Jul 17 '12 at 00:05
  • Can you please copy one of the entries from the OAuth Playground and add it to your question? – Claudio Cherubino Jul 17 '12 at 00:46

2 Answers2

1

Not all file formats support exportLinks and png is one of them. To know all possible import/export combinations, request the About feed and check the importFormats and exportFormats fields:

https://developers.google.com/drive/v2/reference/about#resource

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • Claudio, then I got confused. From my previous [question](http://stackoverflow.com/questions/11265798/getting-public-url-to-file-in-google-drive-using-net-api) I thought the exportLinks was supposed to be used to provide public Url to shared resources. So, how can I get a public url for *any* file stored in the google drive? I am still able to do it doing the workaround: https://docs.google.com/uc?export=download&id={Insert DocId here}, but that's less than ideal. Thanks. – rufo Jul 17 '12 at 13:46
  • The download link for the file with no format conversion is listed in the downloadUrl field – Claudio Cherubino Jul 17 '12 at 16:09
  • Claudio, sorry to keep insisting, but I do not think the downloadUrl is what I am looking for. From your [documentation](https://developers.google.com/drive/v2/reference/files#resource) the downloadUrl = "Short lived download URL for the file. This is only populated for files with content stored in Drive.". I do not want a Short lived URL. I want an static Url. BTW: I do appreciate all the help provided so far. I have made incredible progress in my project (I also realize I am an early adopter). – rufo Jul 17 '12 at 16:33
  • 1
    Unfortunately there's no way to get a long-lived downloadUrl for a file stored on Google Drive – Claudio Cherubino Jul 17 '12 at 16:42
  • Thanks. Not sure if there is a proper path to submit suggestions for the API, but this feature would be helpful. – rufo Jul 17 '12 at 18:21
  • Thanks, this is a common feature request and it is already being considered – Claudio Cherubino Jul 17 '12 at 18:40
0

If you encounter missing exportLinks on Google Docs double check your permissions scope.

Ray Hulha
  • 10,701
  • 5
  • 53
  • 53