Package com.google.gdata.data

Examples of com.google.gdata.data.MediaContent


      } else if (docType.equals("document")) {
        String format = documentList.getDownloadFormat(args[1],
            getTypeFromFilename(args[2]));
        documentList.downloadDocument(args[1], args[2], format);
      } else {
        MediaContent mc = (MediaContent) documentList.getDocsListEntry(args[1]).getContent();
        String fileExtension = mc.getMimeType().getSubType();
        URL exportUrl = new URL(mc.getUri());

        // PDF file cannot be exported in different formats.
        String requestedFormat = args[2]
            .substring(args[2].lastIndexOf(".") + 1);
        if (!requestedFormat.equals(fileExtension)) {

          String[] formatWarning = {"Warning: "
              + mc.getMimeType().getMediaType() + " cannot be downloaded as a "
              + requestedFormat + ". Using ." + fileExtension + " instead."};
          printMessage(formatWarning);
        }
        String newFilePath = args[2].substring(0, args[2].lastIndexOf(".") + 1) + fileExtension;
        documentList.downloadFile(exportUrl, newFilePath);
View Full Code Here


  /**
   * Associate a File with this entry with the specified mime type
   */
  public void setFile(File file, String mimeType) {
    MediaFileSource fileSource = new MediaFileSource(file, mimeType);
    MediaContent content = new MediaContent();
    content.setMediaSource(fileSource);
    content.setMimeType(new ContentType(mimeType));
    setContent(content);
  }
View Full Code Here

      MalformedURLException, ServiceException, DocumentListException {
    if (exportUrl == null || filepath == null) {
      throw new DocumentListException("null passed in for required parameters");
    }

    MediaContent mc = new MediaContent();
    mc.setUri(exportUrl.toString());
    MediaSource ms = service.getMedia(mc);

    InputStream inStream = null;
    FileOutputStream outStream = null;
View Full Code Here

     * @throws MalformedURLException
     */
    public WebAttachmentEntry uploadWebAttachment(String contentUrl,
        FileCabinetPageEntry filecabinet, String title, String description)
        throws MalformedURLException, IOException, ServiceException {
      MediaContent content = new MediaContent();
      content.setUri(contentUrl);

      WebAttachmentEntry webAttachment = new WebAttachmentEntry();
      webAttachment.setTitle(new PlainTextConstruct(title));
      webAttachment.setSummary(new PlainTextConstruct(description));
      webAttachment.setContent(content);
View Full Code Here

    String targetFile = parser.getValue("file");

    System.out.print("Downloading document with id :" + id + " ....");
    System.out.flush();

    MediaContent mc = new MediaContent();
    mc.setUri(feedUrl.toString());
    MediaSource ms = service.getMedia(mc);

    InputStream inStream = null;
    FileOutputStream outStream = null;
    try {
View Full Code Here

      System.out.println("...by appending contents from file " + filename);
      File file = new File(filename);
      String mimeType = "text/xml";

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      requestEntry.setContent(content);
    }

    System.out.print("Updating translation memory....");
View Full Code Here

      System.out.println("...by appending contents from file " + filename);
      File file = new File(filename);
      String mimeType = "text/csv";

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      requestEntry.setContent(content);
    }

    System.out.print("Updating glossaries....");
View Full Code Here

      System.out.println("... with contents from file at " + filename);
      File file = new File(filename);
      String mimeType = MediaType.fromFileName(filename).getMimeType();

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      entry.setContent(content);
    }

    if (parser.containsKey("tmids")) {
View Full Code Here

      System.out.println("...with contents from " + filename);
      File file = new File(filename);
      String mimeType = "text/xml";

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      entry.setContent(content);
    }

    if (parser.containsKey("private")) {
View Full Code Here

    String filename = parser.getValue("file");
    System.out.println("...with contents from " + filename);
    File file = new File(filename);
    String mimeType = "text/csv";
    MediaFileSource fileSource = new MediaFileSource(file, mimeType);
    MediaContent content = new MediaContent();
    content.setMediaSource(fileSource);
    content.setMimeType(new ContentType(mimeType));
    entry.setContent(content);

    return entry;
  }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.MediaContent

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.