Entity currentUser = (Entity) httpRequest.getSession() .getAttribute("userObject");
Query query = new Query("GoogleAccount", currentUser.getKey());Entity googleAccount = dataService.prepare(query).asSingleEntity();GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();oauthParameters.setOAuthConsumerKey( oauthProps.getProperty("google.consumerKey"));oauthParameters.setOAuthConsumerSecret( oauthProps.getProperty("google.consumerSecret"));oauthParameters.setOAuthToken( (String) googleAccount.getProperty("oauthToken"));oauthParameters.setOAuthTokenSecret( (String) googleAccount.getProperty("oauthSecret"));
MediaStreamSource
DocsService service = new DocsService("Socialwok-v1");service.setOAuthCredentials(oauthParameters,signer);MediaStreamSource streamSource = new MediaStreamSource(fileInputStream, contentType);streamSource.setName(filename);DocumentListEntry inserted = service.insert( new URL( "http://docs.google.com/feeds/default/private/full/?convert="+ doConvert), DocumentListEntry.class, streamSource);
convert
https://docs.google.com/a/socialwok.com/View?docid=0Adnk...dkZmNoOTIyNQ
https://docs.google.com/a/socialwok.com/Doc?docid=0Adnk...dkZmNoOTIyNQ
Entity fileAttachment = datastoreService.get(attachmentKey);String entryId = fileAttachment.getProperty("fileId");
URL entryUrl = new URL(entryId);DocumentListEntry docEntry = service.getEntry(entryUrl, DocumentListEntry.class);
String docLink = docEntry.getDocumentLink().getHref();
if (docEntry instanceof DocumentEntry) { docLink = docLink.replace("/Doc","/View");}
<iframe>
import com.google.gwt.user.client.ui.Frame;...Frame viewerFrame = new Frame();viewerFrame.setUrl(docLink);viewerFrame.setHeight("500px");viewerFrame.setWidth("600px");containerWidget.add(viewerFrame);
https://docs.google.com/a/<domain>/Doc?docid=...
https://docs.google.com/a/<domain>/View?docid=...
https://docs.google.com/a/<domain>/present/edit?id=...
https://docs.google.com/a/<domain>/present/view?id=...
https://spreadsheets.google.com/a/<domain>/ccc?key=...
https://spreadsheets.google.com/a/<domain>/lv?key=...
url
embedded
http://labs.google.com/papers/bigtable-osdi06.pdf
http://docs.google.com/viewer?url=https%3A%2F%2F2.gy-118.workers.dev/%3A443%2Fhttp%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf
http://docs.google.com/viewer?url=https%3A%2F%2F2.gy-118.workers.dev/%3A443%2Fhttp%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf&embedded=true
<IFRAME>
<iframe src="">http://docs.google.com/viewer?url=https%3A%2F%2F2.gy-118.workers.dev/%3A443%2Fhttp%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
Frame
import com.google.gwt.user.client.ui.Frame;...Frame viewerFrame = new Frame();viewerFrame.setUrl("http://docs.google.com/viewer?url=https%3A%2F%2F2.gy-118.workers.dev/%3A443%2Fhttp%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf&embedded=true");viewerFrame.setHeight("500px");viewerFrame.setWidth("600px");containerWidget.add(viewerFrame);