• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MediaFileSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.gdata.data.media.MediaFileSource的典型用法代码示例。如果您正苦于以下问题:Java MediaFileSource类的具体用法?Java MediaFileSource怎么用?Java MediaFileSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MediaFileSource类属于com.google.gdata.data.media包,在下文中一共展示了MediaFileSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
@Override
public void execute() throws Exception {
  MediaFileSource media = new MediaFileSource(new File(attachmentFile), attachmentMimeType);
  
  Service service = createService();
  Service.GDataRequest request = service.createRequest(GDataRequest.RequestType.INSERT, 
      new URL(itemMediaUrl), new ContentType(attachmentMimeType));

  if (caption != null) {
    request.setHeader("Slug", caption);
  }
  
  MediaSource.Output.writeTo(media, request.getRequestStream());

  // Send the request (HTTP POST)
  request.execute();

  // Save the response
  outputRawResponse(request);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:21,代码来源:InsertMediaCommand.java


示例2: createEntryFromArgs

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
private GlossaryEntry createEntryFromArgs(String[] args)
    throws IOException {
  SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

  System.out.println("You asked to add a glossary...");

  GlossaryEntry entry = new GlossaryEntry();

  String title = parser.getValue("title");
  System.out.println("...with title " + title);
  entry.setTitle(new PlainTextConstruct(title));

  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;
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:25,代码来源:AddGlossaryCommand.java


示例3: createResumableUploadSession

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Creates a resumable upload session for a new media.
 *
 * @param createMediaUrl resumable put/post url.
 * @param title media title for new upload or {@code null} for updating
 *              media part of existing media resource.
 * @param file  new media file to upload.
 * @return resumable upload url to upload the media to.
 * @throws IOException error communicating with the GData service.
 * @throws ServiceException insert request failed due to system error.
 */
URL createResumableUploadSession(
    URL createMediaUrl, String title, MediaFileSource file)
    throws IOException, ServiceException {

  String mimeType = file.getContentType();
  GDataRequest request = createRequest(GDataRequest.RequestType.INSERT,
      createMediaUrl, new ContentType(mimeType));
  initResumableMediaRequest(request, file, title);
  try {
    startVersionScope();
    request.execute();
    return new URL(request.getResponseHeader("Location"));
  } finally {
    endVersionScope();
    request.end();
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:29,代码来源:MediaService.java


示例4: uploadVideo

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Metóda uploadVideo slúži na odovzdanie multimediálneho video a súboru na server YouTube. Taktiež priradzuje k videu aj  detaily o videosúbore a detaily o serveri s kadiaľ je odovzdávaný.
 * @param file - video multimediálny súbor, zapísaný v štruktúre FileImpl
 * @param user - používateľ (majiteľ), ktorý daný video multimediálnych súbor odovzdáva z potálu
 * @param name - názov vytváranej trasy ku ktorej daný súbor patrí
 * @param ID - poradove číslo multimediálneho súboru v danej trase
 * @return Navratová hodnota je ID daného odovzdaneho multimedialneho súboru, pomocou ktoreho sa ten da vyvolať na serveri YouTube
 * @throws YouTubeAgentException je vyhodená ppri problemoch s odovzdaním video multimediálneho súboru
 */
public String uploadVideo (FileImpl file, String user, String name, String ID) throws YouTubeAgentException{
    try {
        VideoEntry newEntry = new VideoEntry();
        
       YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
            mg.setTitle(new MediaTitle());
            mg.getTitle().setPlainTextContent(user + "=" + name + "=" + ID);
            mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos"));
            mg.setKeywords(new MediaKeywords());
            mg.getKeywords().addKeyword("GPSWebApp");
            mg.setDescription(new MediaDescription());
            mg.getDescription().setPlainTextContent("This video has been uploaded from GPSWebApp server, and it is property of GPSWebApp server.");
            //mg.setPrivate(true);
            //mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag"));
            //mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "anotherdevtag"));
        
        MediaFileSource ms = new MediaFileSource(new File(file.getPath()), "video/quicktime");
        newEntry.setMediaSource(ms);
        String uploadUrl = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
  //      
        XmlBlob xmlBlob = new XmlBlob(); 
        xmlBlob.setBlob("<yt:accessControl action='list' permission='denied'/>"); 
        newEntry.setXmlBlob(xmlBlob); 
  //      
        VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
        System.out.println("Video has been uploaded to YouTube: " + createdEntry.getMediaGroup().getPlayer().getUrl());
        FileLogger.getInstance().createNewLog("Successfully uploaded video to YouTube with URL " + createdEntry.getMediaGroup().getPlayer().getUrl() + " .");
        
        
        return createdEntry.getMediaGroup().getVideoId();
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("ERROR: Cannot upload video to YouTube server!!!");
        FileLogger.getInstance().createNewLog("ERROR: Cannot upload video to YouTube with ID !!!");
        throw new YouTubeAgentException();
    }
}
 
开发者ID:lp190zn,项目名称:gTraxxx,代码行数:47,代码来源:YouTubeAgent.java


示例5: getMediaFileSource

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
private MediaFileSource getMediaFileSource(String fileName) {
  File file = new File(fileName);
  MediaFileSource mediaFile = new MediaFileSource(file,
      DocumentListEntry.MediaType.fromFileName(file.getName())
          .getMimeType());
  return mediaFile;
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:8,代码来源:DocumentResumableUploadDemo.java


示例6: executeUpdate

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Execute 'update' command.
 */
private void executeUpdate(String[] args)
    throws IOException, ServiceException, InterruptedException {
  String docIdToUpdate = args[1];
  String filePath = args[2];

  // retrieve latest entry
  DocumentListEntry currentEntry = docs.service.getEntry(
      new URL(DEFAULT_DOCLIST_FEED_URL  + "/" + docIdToUpdate),
      DocumentListEntry.class);

  MediaFileSource mediaFile = getMediaFileSource(filePath);
  ResumableGDataFileUploader uploader =
      new ResumableGDataFileUploader
          .Builder(docs.service, mediaFile, currentEntry)
          .title(mediaFile.getName())
          .requestType(
              ResumableGDataFileUploader.RequestType.UPDATE_MEDIA_ONLY)
          .build();

  uploader.start();

  // wait for upload to complete
  while (!uploader.isDone()) {
    try {
      Thread.sleep(100);
    } catch (InterruptedException ie) {
      output.println("Media update interrupted at: "
          + String.format("%3.0f", uploader.getProgress() * 100) + "%");
      throw ie; // rethrow
    }
  }
  DocumentListEntry updatedEntry =
      uploader.getResponse(DocumentListEntry.class);

  output.println("Finished update");
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:40,代码来源:DocumentResumableUploadDemo.java


示例7: uploadAttachment

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Uploads an attachment to a parent page.
 *
 * @param file The file contents to upload
 * @param parentLink Full self id of the parent entry to upload the attach to.
 * @param title A title for the attachment.
 * @param description A description for the attachment.
 * @return The created attachment entry.
 * @throws ServiceException
 * @throws IOException
 */
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);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:24,代码来源:SitesHelper.java


示例8: updateAttachment

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Updates an existing attachment's metadata and content.
 *
 * @param entry Attachment entry to update.
 * @param newFile The replacement file content.
 * @param newTitle A new title for the attachment.
 * @param newDescription A new description for the attachment.
 * @return The created attachment.
 * @throws ServiceException
 * @throws IOException
 */
public AttachmentEntry updateAttachment(AttachmentEntry entry, File newFile,
    String newTitle, String newDescription) throws IOException, ServiceException  {
  entry.setMediaSource(new MediaFileSource(newFile, mediaTypes.getContentType(newFile)));
  if (newTitle != null) {
    entry.setTitle(new PlainTextConstruct(newTitle));
  }
  if (newDescription != null) {
    entry.setSummary(new PlainTextConstruct(newDescription));
  }

  return entry.updateMedia(true);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:24,代码来源:SitesHelper.java


示例9: createEntryFromArgs

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
private TranslationMemoryEntry createEntryFromArgs(String[] args)
    throws IOException {
  SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

  System.out.println("You asked to add translation memory...");

  TranslationMemoryEntry entry = new TranslationMemoryEntry();

  String title = parser.getValue("title");
  System.out.println("...with title " + title);
  entry.setTitle(new PlainTextConstruct(title));

  if (parser.containsKey("file")) {
    String filename = parser.getValue("file");
    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")) {
    System.out.println("...with private access");
    entry.setScope(new ScopeEntry(ScopeEntry.Value.PRIVATE));
  } else {
    System.out.println("...with public access");
    entry.setScope(new ScopeEntry(ScopeEntry.Value.PUBLIC));
  }

  return entry;
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:37,代码来源:AddTranslationMemoryCommand.java


示例10: setFile

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:11,代码来源:DocumentListEntry.java


示例11: initResumableMediaRequest

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Initialize a resumable media upload request.
 *
 * @param request {@link GDataRequest} to initialize.
 * @param file    media file that needs to be upload.
 * @param title   title of uploaded media or {@code null} if no title.
 */
private void initResumableMediaRequest(
    GDataRequest request, MediaFileSource file, String title) {
  initMediaRequest(request, title);
  request.setHeader(
      GDataProtocol.Header.X_UPLOAD_CONTENT_TYPE, file.getContentType());
  request.setHeader(GDataProtocol.Header.X_UPLOAD_CONTENT_LENGTH,
      new Long(file.getContentLength()).toString());
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:16,代码来源:MediaService.java


示例12: createResumableUpdateSession

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
/**
 * Creates a resumable upload session to update existing media.
 *
 * @param editMediaUrl resumable put/post url.
 * @param entry media entry to update.
 * @param file updated media file to upload.
 * @param isMediaOnly whether to update media only or both media and metadata.
 *                    {@code true} if media-only or {@code false} for both.
 * @return resumable upload url to upload the media to.
 * @throws IOException error communicating with the GData service.
 * @throws ServiceException insert request failed due to system error.
 */
URL createResumableUpdateSession(
    URL editMediaUrl, IEntry entry, MediaFileSource file, boolean isMediaOnly)
    throws IOException, ServiceException {

  GDataRequest request;
  if (isMediaOnly) {
    request = createRequest(GDataRequest.RequestType.UPDATE, editMediaUrl,
        new ContentType(file.getContentType()));
  } else {
    request = createUpdateRequest(editMediaUrl);
  }
  initResumableMediaRequest(request, file, null);
  if (entry.getEtag() != null) {
    request.setEtag(entry.getEtag());
  }
  try {
    startVersionScope();
    if (!isMediaOnly) {
      writeRequestData(request, entry);
    }
    request.execute();
    return new URL(request.getResponseHeader("Location"));
  } finally {
    endVersionScope();
    request.end();
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:40,代码来源:MediaService.java


示例13: createPhotoEntry

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
public PhotoEntry createPhotoEntry (String title, String description, File fileImage) {
	PhotoEntry myPhoto = new PhotoEntry();
	myPhoto.setTitle(new PlainTextConstruct(title));
	myPhoto.setDescription(new PlainTextConstruct(description));
	myPhoto.setClient( QuizParserConstant.SYNC_CLIENT_NAME );

	MediaFileSource myMedia = new MediaFileSource(fileImage, "image/jpeg");
	myPhoto.setMediaSource(myMedia);
	
	return myPhoto;
}
 
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:12,代码来源:PicasawebClient.java


示例14: writeEndWiki

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
@Override
public void writeEndWiki() throws IOException {
  progressListener.setStatus("Processing Attachments.");
  progressListener.setProgress(.5);  // Arbitrarily chosen.

  allImages.removeAll(attachments.keySet());
  for (String image : allImages) {
    attachments.put(image, Lists.<BasePageEntry<?>>newLinkedList());
  }

  for (Map.Entry<String, List<BasePageEntry<?>>>
       entry : attachments.entrySet()) {
    String name = entry.getKey();
    progressListener.setStatus("Attachment: " + name);
    AttachmentEntry attachment = new AttachmentEntry();
    File file = new File(imagesDirectory, name);
    String type = URLConnection.guessContentTypeFromName(file.getName());
    MediaSource mediaSource = new MediaFileSource(file, type);
    attachment.setMediaSource(mediaSource);
    attachment.setTitle(TextConstruct.plainText(name));
    pageImporter.importAttachment(
        attachment, entry.getValue(),
        feedUrl, sitesService);
  }

  progressListener.setStatus("Processed End of Wiki.");
  progressListener.setProgress(.9);  // Arbitrarily chosen.
}
 
开发者ID:roubert,项目名称:mediawiki-googlesites,代码行数:29,代码来源:SiteImporterImpl.java


示例15: execute

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
public void execute(GttService service, String[] args)
    throws IOException, ServiceException {
  SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

  String id = parser.getValue("id");
  URL feedUrl = FeedUris.getTranslationMemoryFeedUrl(id);

  TranslationMemoryEntry requestEntry = service.getEntry(feedUrl,
      TranslationMemoryEntry.class);

  System.out.println("You want to update translation memory with id:"
      + id + " ...");

  if (parser.containsKey("title")) {
    String title = parser.getValue("title");
    System.out.println("...by changing title to " + title);
    requestEntry.setTitle(new PlainTextConstruct(title));
  }

  if (parser.containsKey("file")) {
    String filename = parser.getValue("file");
    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....");
  System.out.flush();

  TranslationMemoryEntry resultEntry = null;
  if (requestEntry.getContent() == null) {
    resultEntry = service.update(feedUrl, requestEntry);
  } else {
    resultEntry = service.updateMedia(feedUrl, requestEntry);
  }

  printResults(resultEntry);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:46,代码来源:UpdateTranslationMemoryCommand.java


示例16: execute

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
public void execute(GttService service, String[] args)
    throws IOException, ServiceException {
  SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

  String id = parser.getValue("id");
  URL feedUrl = FeedUris.getGlossaryFeedUrl(id);

  GlossaryEntry requestEntry = service.getEntry(feedUrl, GlossaryEntry.class);

  System.out.println("You want to update glossary with id:" + id + " ...");

  if (parser.containsKey("title")) {
    String title = parser.getValue("title");
    System.out.println("...by changing title to " + title);
    requestEntry.setTitle(new PlainTextConstruct(title));
  }

  if (parser.containsKey("file")) {
    String filename = parser.getValue("file");
    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....");
  System.out.flush();
  GlossaryEntry resultEntry = null;
  if (requestEntry.getContent() == null) {
    resultEntry = service.update(feedUrl, requestEntry);
  } else {
    resultEntry = service.updateMedia(feedUrl, requestEntry);
  }

  printResults(resultEntry);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:43,代码来源:UpdateGlossaryCommand.java


示例17: uploadImageToAlbum

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
public GphotoEntry uploadImageToAlbum(File imageFile, GphotoEntry remotePhoto, GphotoEntry albumEntry, String localMd5CheckSum ) throws Exception {

        boolean newPhoto = false;
        String albumName = albumEntry.getTitle().getPlainText();
        PhotoEntry  myPhoto = new PhotoEntry();
        
        if( remotePhoto == null || !StringUtils.hasValue(remotePhoto.getId()) )
        {
            newPhoto = true;
            log.info( "Uploading new image to album " + albumName + ": " + imageFile);
        }
        else{
        	// BeanUtils.copyProperties(myPhoto, remotePhoto);
        	remotePhoto.delete();
            log.info( "Uploading updated image in album " + albumName + ": " + imageFile);
        }


        try{
        	MediaFileSource myMedia = new MediaFileSource(imageFile, "image/jpeg");
        	myPhoto.setMediaSource(myMedia);
			myPhoto.setChecksum( localMd5CheckSum );
			myPhoto.setAlbumAccess(GphotoAccess.Value.PUBLIC);
			myPhoto.setClient( QuizParserConstant.SYNC_CLIENT_NAME );
			
            if( newPhoto)
            {
                myPhoto.setTitle(new PlainTextConstruct(imageFile.getName()));
            }
            else
            {
            	myPhoto.setTitle(remotePhoto.getTitle());
            }
            
            myPhoto = insert(albumEntry, myPhoto);
        } catch (Exception ex) {
            log.error("Unable to add media: " + imageFile + ": " + ex);
        } finally {
        	 setUpdatedDate( albumEntry, myPhoto, imageFile );
        }
        
        return myPhoto;
    }
 
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:44,代码来源:PicasawebClient.java


示例18: importPage

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
@Override
public BasePageEntry<?> importPage(File directory, boolean importRevisions, 
    List<BasePageEntry<?>> ancestors, URL feedUrl, URL siteUrl, 
    SitesService sitesService) {
  checkNotNull(directory);
  File file = new File(directory, "index.html");
  if (!file.isFile()) {
    LOGGER.log(Level.WARNING, "No valid file in directory: " + directory);
    return null;
  }
  List<BaseContentEntry<?>> entries = pageParser.parsePage(file);
  BasePageEntry<?> page = getFirstPageEntry(entries);
  if (page == null) {
    LOGGER.log(Level.WARNING, "No valid page entry!");
    return null;
  }
  
  page.setPageName(new PageName(directory.getName()));
  linkConverter.convertLinks(page, ancestors, siteUrl, false);
  if (!ancestors.isEmpty()) {
    EntryUtils.setParent(page, ancestors.get(ancestors.size() - 1));
  }
  BasePageEntry<?> returnedEntry = null;
  if (importRevisions && new File(directory, "_revisions").isDirectory()) {
    returnedEntry = revisionsImporter.importRevisions(
        directory, ancestors, feedUrl, siteUrl, sitesService);
  }
  if (returnedEntry == null) {
    returnedEntry = (BasePageEntry<?>) entryUploader.uploadEntry(
        page, ancestors, feedUrl, sitesService);
  } else {
    returnedEntry = (BasePageEntry<?>) entryUpdater.updateEntry(
        returnedEntry, page, sitesService);
  }
  
  List<BasePageEntry<?>> newAncestors = Lists.newLinkedList(ancestors);
  newAncestors.add(returnedEntry);
  for (BaseContentEntry<?> child : getNonPageEntries(entries)) {
    if (getType(child) == ATTACHMENT) {
      if (child.getContent() != null) {
        String src = ((OutOfLineContent) child.getContent()).getUri();
        File attachmentFile = new File(directory, src);
        MediaSource mediaSource = new MediaFileSource(attachmentFile, 
            "application/octet-stream");
        child.setContent((Content) null);
        child.setMediaSource(mediaSource);
      } else {
        System.out.println(child.getTitle().getPlainText());
      }
    }
    EntryUtils.setParent(child, returnedEntry);
    entryUploader.uploadEntry(child, newAncestors, feedUrl, sitesService);
  }
  return returnedEntry;
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:56,代码来源:PageImporterImpl.java


示例19: uploadImageToAlbum

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
public boolean uploadImageToAlbum(File imageFile, PhotoEntry remotePhoto, AlbumEntry albumEntry, String localMd5CheckSum ) throws IOException, ServiceException {

        boolean success = false;
        boolean newPhoto = false;
        String albumName = albumEntry.getTitle().getPlainText();
        PhotoEntry myPhoto = remotePhoto;

        if (myPhoto == null)
        {
            newPhoto = true;
            log.info("Uploading new image to album " + albumName + ": " + imageFile);

            myPhoto = new PhotoEntry();
        }
        else
        {
            log.info("Uploading updated image in album " + albumName + ": " + imageFile);
            List<MediaContent> media = myPhoto.getMediaContents();
            media.remove(0);
        }

        try
        {
            MediaFileSource myMedia = new MediaFileSource(imageFile, "image/jpeg");
            myPhoto.setMediaSource(myMedia);
            myPhoto.setChecksum(localMd5CheckSum);
            myPhoto.setClient(SYNC_CLIENT_NAME);

            if (newPhoto)
            {
                myPhoto.setTitle(new PlainTextConstruct(imageFile.getName()));
                myPhoto = insert(albumEntry, myPhoto);
                success = true;
            }
            else
            {
                myPhoto = myPhoto.updateMedia(true);
                success = true;
            }
        }
        catch (Exception ex)
        {
            log.error("Unable to add media: " + imageFile + ": " + ex);
        }

        if( success )
            setUpdatedDate(albumEntry, myPhoto, imageFile);

        return success;
    }
 
开发者ID:Webreaper,项目名称:GooglePhotoSync,代码行数:51,代码来源:PicasawebClient.java


示例20: getMediaFileSource

import com.google.gdata.data.media.MediaFileSource; //导入依赖的package包/类
private MediaFileSource getMediaFileSource(File file) {    
  MediaFileSource mediaFile = new MediaFileSource(file,
      DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType());    
  return mediaFile;
}
 
开发者ID:eduardoguzman,项目名称:sisob-data-extractor,代码行数:6,代码来源:DocumentUploader.java



注:本文中的com.google.gdata.data.media.MediaFileSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SharedSecrets类代码示例发布时间:2022-05-22
下一篇:
Java Context类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap