Package com.google.gdata.data.sites

Examples of com.google.gdata.data.sites.AttachmentEntry


 
  public AttachmentEntry uploadAttachment(File file, String parentLink, String description)
      throws IOException, ServiceException  {
    String fileMimeType = mediaTypes.getContentType(file);
   
    AttachmentEntry newAttachment = new AttachmentEntry();
    newAttachment.setMediaSource(new MediaFileSource(file, fileMimeType));
    newAttachment.setTitle(new PlainTextConstruct(file.getName()));
    newAttachment.setSummary(new PlainTextConstruct(description));
    newAttachment.addLink(SitesLink.Rel.PARENT, Link.Type.ATOM, parentLink);
   
    return service.insert(new URL(getContentFeedUrl()), newAttachment);
  }
View Full Code Here


      System.out.print("Enter file description: ");
      String description = reader.readLine();
     
      File file = new File(filename);
      String mediaType = demo.mediaTypes.getContentType(file);
      AttachmentEntry attachment =
        demo.uploadAttachment(file, entry.getSelfLink().getHref(), description);
      System.out.println("\nFiled uploaded! See it: " +
          attachment.getLink(Link.Rel.ALTERNATE, mediaType).getHref() + "\n");
    }
  }
View Full Code Here

     * Order of declaration is important. */
    extProfile.setAutoExtending(true);
    new ActivityFeed().declareExtensions(extProfile);
    new AnnouncementEntry().declareExtensions(extProfile);
    new AnnouncementsPageEntry().declareExtensions(extProfile);
    new AttachmentEntry().declareExtensions(extProfile);
    new CommentEntry().declareExtensions(extProfile);
    new ContentFeed().declareExtensions(extProfile);
    new CreationActivityEntry().declareExtensions(extProfile);
    new DeletionActivityEntry().declareExtensions(extProfile);
    new EditActivityEntry().declareExtensions(extProfile);
View Full Code Here

     * @throws ServiceException
     * @throws IOException
     */
    public void downloadAttachment(String entryId, String directory)
        throws IOException, ServiceException {
      AttachmentEntry attachment = service.getEntry(
          new URL(getContentFeedUrl() + entryId), AttachmentEntry.class);
      String url = ((OutOfLineContent) attachment.getContent()).getUri();
      ///*MediaSource mediaSource = service.getMedia((MediaContent) entry.getContent());*/
      downloadFile(url, directory + attachment.getTitle().getPlainText());
    }
View Full Code Here

     */
    public AttachmentEntry uploadAttachment(File file, String parentLink, String title,
        String description) throws IOException, ServiceException  {
      String fileMimeType = mediaTypes.getContentType(file);

      AttachmentEntry newAttachment = new AttachmentEntry();
      newAttachment.setMediaSource(new MediaFileSource(file, fileMimeType));
      newAttachment.setTitle(new PlainTextConstruct(title));
      newAttachment.setSummary(new PlainTextConstruct(description));
      newAttachment.addLink(SitesLink.Rel.PARENT, Link.Type.ATOM, parentLink);

      return service.insert(new URL(getContentFeedUrl()), newAttachment);
    }
View Full Code Here

      if (args.length < 3) {
        throw new SitesException("Wrong number of args");
      }

      try {
        AttachmentEntry newEntry = null;
        if (args.length == 4) {
          newEntry = sitesHelper.uploadAttachment(
              args[1], sitesHelper.getContentFeedUrl() + args[2], args[3]);
        else {
          newEntry = sitesHelper.uploadAttachment(
              args[1], sitesHelper.getContentFeedUrl() + args[2], "");
        }

        if (newEntry.getHtmlLink() != null) {
          System.out.println("View it at " + newEntry.getHtmlLink().getHref());
        }
      } catch (VersionConflictException e) {
        System.err.println(e.getResponseBody());
      }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.sites.AttachmentEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.