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=http%3A%2F%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf
http://docs.google.com/viewer?url=http%3A%2F%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf&embedded=true
<IFRAME>
<iframe src="">http://docs.google.com/viewer?url=http%3A%2F%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=http%3A%2F%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf&embedded=true");viewerFrame.setHeight("500px");viewerFrame.setWidth("600px");containerWidget.add(viewerFrame);