0

I've uploaded a (pgp) file via the documents API, and changed its visibility to public. However, I'm unable to download it publicly using the contents link for that file.

Here are the relevant bits of the xml for the meta-data for the file in question.

$ curl -H "GData-Version: 3.0" -H "Authorization: Bearer ..." https://docs.google.com/feeds/default/private/full

...
    <content type="application/pgp-encrypted" src="https://doc-0c-c0-docs.googleusercontent.com/docs/securesc/tkl8gnmcm9fhm6fec3160bcgajgf0i18/opa6m1tmj5cufpvrj89bv4dt0q6696a4/1336514400000/04627947781497054983/04627947781497054983/0B_-KWHz80dDXZ2dYdEZ0dGw3akE?h=16653014193614665626&amp;e=download&amp;gd=true"/>
...
    <gd:feedLink rel="http://schemas.google.com/acl/2007#accessControlList" href="https://docs.google.com/feeds/default/private/full/file%3A0B_-KWHz80dDXZ2dYdEZ0dGw3akE/acl"/>

$ curl -H "GData-Version: 3.0" -H "Authorization: Bearer ..." https://docs.google.com/feeds/default/private/full/file%3A0B_-KWHz80dDXZ2dYdEZ0dGw3akE/acl

...
  <entry gd:etag="W/&quot;DUcNRns4eCt7ImA9WhVVFUw.&quot;">
    <id>https://docs.google.com/feeds/id/file%3A0B_-KWHz80dDXZ2dYdEZ0dGw3akE/acl/default</id>
...
    <gAcl:role value="reader"/>
    <gAcl:scope type="default"/>
...

The role/scope returned for the file in question is reader/default, indicating it is public. (It also shows up with public shared access in the web UI.)

However, accessing the src attribute in the content element results in:

$ curl --verbose 'https://doc-0c-c0-docs.googleusercontent.com/docs/securesc/tkl8gnmcm9fhm6fec3160bcgajgf0i18/opa6m1tmj5cufpvrj89bv4dt0q6696a4/1336514400000/04627947781497054983/04627947781497054983/0B_-KWHz80dDXZ2dYdEZ0dGw3akE?h=16653014193614665626&e=download&gd=true'

< HTTP/1.1 401 Unauthorized
< Server: HTTP Upload Server Built on May 7 2012 18:16:42 (1336439802)
< WWW-Authenticate: GoogleLogin realm="http://www.google.com/accounts"
< Date: Tue, 08 May 2012 22:48:37 GMT
< Expires: Tue, 08 May 2012 22:48:37 GMT
< Cache-Control: private, max-age=0
< Content-Length: 0
< Content-Type: text/html
kbs
  • 505
  • 5
  • 8
  • As Claudio points out below, google docs/drive does not allow _public_ direct download links for anything. – kbs May 10 '12 at 20:15

1 Answers1

1

It seems like you are trying to publish a document: https://developers.google.com/google-apps/documents-list/#publishing_documents_by_publishing_a_single_revision

Once you publish it, the link with rel set to "http://schemas.google.com/docs/2007#publish" will point to the published document on the web.

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • Thank you for the pointer. I'm not trying to publish a document however, just trying to get a direct download link to an uninterpreted file (eg: mime-type in the example above is not a document.) Does all this mean direct download links to non-documents are just not permitted in google docs/drive? – kbs May 10 '12 at 18:42
  • Direct downloads are only allowed when the request is authorized – Claudio Cherubino May 10 '12 at 19:24
  • To share a file publicly, you can look at the steps available in the StackOverflow [answer](http://stackoverflow.com/questions/8084338/java-google-api-publish-a-document/10036474#10036474). This will make the file available to the world; once this is done, you can get the file's web URL from the Documents List API (look for a link with `rel="alternate"`). – Alain May 10 '12 at 21:45