How to publish Google Docs in .NET?

I am using google-gdata .NET library to integrate with Google Docs. This works very well, but I canโ€™t figure out how to use it to publish my documents for web-based access only based on browsing.

The basic idea is to upload the document to Google Docs and be able to view the document in a web environment (outside of Google) without having to log in using Google credentials. As far as I can tell, the best way to do this is to publish it through a secret link, as described in the help article above.

So does anyone know how to publicly publish Google Docs in .NET?

EDIT

As a starting point and as an illustration of the difference between changing the ACL on a document (i.e. publishing it) and publishing the document itself (as described above in the link), these are the corresponding versions of the same document in Google Docs:

+4
source share
2 answers

I just updated the .NET client library, now you can use the following code to publish the version (it is assumed that entry is the DocumentEntry instance that you want to publish):

 RevisionQuery revisionQuery = new RevisionQuery(entry.RevisionDocument); RevisionFeed revisions = service.Query(revisionQuery); // TODO: choose the revision you want to publish, this sample selects the first one RevisionEntry revision = (RevisionEntry)revisions.Entries[0]; revision.Publish = true; revision.PublishAuto = true; revision.Update(); 
+3
source

This post has already been answered with a snippet of Java code. For .NET, you should do something like this:

 AclEntry aclEntry = new AclEntry(); aclEntry.Role = new AclRole("reader"); aclEntry.Scope = new AclScope(AclScope.SCOPE_DEFAULT); // documentEntry is the document that you want to publish and service is an // authorized DocumentsService object. AclEntry insertedEntry = service.Insert( new Uri(documentEntry.AccessControlList), aclEntry); 
+2
source

Source: https://habr.com/ru/post/1402230/


All Articles