Package com.google.gdata.data.media

Examples of com.google.gdata.data.media.MediaByteArraySource


      throw new IllegalArgumentException(Messages.get("album_not_found",
          albumId));
    }
    PhotoEntry photo = new PhotoEntry();
    photo.setTitle(new PlainTextConstruct(name));
    MediaSource mediaSource = new MediaByteArraySource(data,
        MimeType.getContentTypeByExt(FolderUtil.getFileExt(name)));
    photo.setMediaSource(mediaSource);
    return getPicasawebService().insert(new URL(getPicasaURL(albumId)),
        photo);
  }
View Full Code Here


    DocsService svc = getDocsService();
    DocumentEntry newDocument = new DocumentEntry();
    newDocument.setTitle(new PlainTextConstruct(title));
    DocumentEntry entry;
    try {
      MediaByteArraySource source = new MediaByteArraySource(contents.getBytes("UTF8"), "text/plain");
      newDocument.setMediaSource(source);
      entry = svc.insert(new URL(DOCS_SCOPE + "default/private/full"), newDocument);
    } catch (Exception e) {
      e.printStackTrace();
      throw new DocumentServiceException(e.getMessage());
View Full Code Here

  @Override
  public DocumentServiceEntry setDocumentContents(String documentId, String etag, String contents) throws DocumentServiceException {
    DocsService svc = getDocsService();
    svc.getRequestFactory().setHeader("If-Match", etag);
    try {
    MediaByteArraySource source = new MediaByteArraySource(contents.getBytes("UTF8"), "text/plain");
    String editMediaUri = DOCS_SCOPE + "default/media/document%3A" + documentId;
    DocumentListEntry entry = svc.updateMedia(new URL(editMediaUri), DocumentListEntry.class, source);
    entry = getDocumentEntry(documentId, etag);
    return getDocumentReference(entry);
    } catch (Exception e) {
View Full Code Here

      e.printStackTrace();
    }
  }

  public DocumentListEntry updateDocumentFile(DocumentListEntry entry, String content, String mediaType) throws IOException, ServiceException {
    entry.setMediaSource(new MediaByteArraySource(content.getBytes(), mediaType));
    return entry.updateMedia(true);
  }
View Full Code Here

  }

  public DocumentListEntry uploadFile(byte[] mediaBytes, String mediaType, String title, String folder) throws IOException, ServiceException, URISyntaxException {
    DocumentListEntry newEntry = new DocumentListEntry();
    newEntry.setTitle(new PlainTextConstruct(title));
    newEntry.setMediaSource(new MediaByteArraySource(mediaBytes, mediaType));
    DocumentListEntry folderEntry = findDocumentFolderEntry(folder);
    if (folderEntry != null) {
      return documentsService.insert(new URL(((MediaContent) folderEntry.getContent()).getUri()), newEntry);
    }
    return documentsService.insert(documentsFeedUri, newEntry);
View Full Code Here

  }

  public PhotoEntry uploadImage(byte[] mediaBytes, String mediaType, String imageName, String albumName) throws IOException, ServiceException {
    PhotoEntry myPhoto = new PhotoEntry();
    myPhoto.setTitle(new PlainTextConstruct(imageName));
    MediaByteArraySource myMedia = new MediaByteArraySource(mediaBytes, mediaType);
    myPhoto.setMediaSource(myMedia);
    AlbumEntry albumEntry = getAlbum(albumName);
    if (albumEntry != null) {
      return photoService.insert(new URL(((MediaContent) albumEntry.getContent()).getUri()), myPhoto);
    }
View Full Code Here

      URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/");
      DocumentListEntry newEntry = new DocumentEntry();
      newEntry.setTitle(new PlainTextConstruct(title));
      newEntry = client().insert(feedUrl, newEntry);
     
      newEntry.setMediaSource(new MediaByteArraySource(content.getBytes(), "text/html"));
      newEntry = newEntry.updateMedia(true);
      return newEntry;
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
View Full Code Here

            URL feedUrl = new URL(destFolderUrl);
            DocumentListEntry newEntry = new DocumentEntry();
            newEntry.setTitle(new PlainTextConstruct(title));
            newEntry = client().insert(feedUrl, newEntry);
            newEntry.setEtag("*");
            newEntry.setMediaSource(new MediaByteArraySource(
                    content.getBytes(), "text/html"));
            newEntry.updateMedia(true);
            return newEntry;

        } catch (MalformedURLException e) {
View Full Code Here

TOP

Related Classes of com.google.gdata.data.media.MediaByteArraySource

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.