Package com.google.gdata.client.media

Examples of com.google.gdata.client.media.ResumableGDataFileUploader


        Executors.newFixedThreadPool(MAX_CONCURRENT_UPLOADS);
    // Create {@link ResumableGDataFileUploader} for each file to upload
    List<ResumableGDataFileUploader> uploaders = Lists.newArrayList();
    for (String fileName : files) {
      MediaFileSource mediaFile = getMediaFileSource(fileName);
      ResumableGDataFileUploader uploader =
          new ResumableGDataFileUploader.Builder(
              docs.service, new URL(url), mediaFile, null /*empty meatadata*/)
              .title(mediaFile.getName())
              .chunkSize(chunkSize).executor(executor)
              .trackProgress(listener, PROGRESS_UPDATE_INTERVAL)
              .build();
      uploaders.add(uploader);
    }
    // attach the listener to list of uploaders
    listener.listenTo(uploaders);

    // Start the upload
    for (ResumableGDataFileUploader uploader : uploaders) {
      uploader.start();
    }

    // wait for uploads to complete
    while (!listener.isDone()) {
      try {
View Full Code Here


    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");
  }
View Full Code Here

    mg.getKeywords().addKeyword("gdata-test");
    mg.setDescription(new MediaDescription());
    mg.getDescription().setPlainTextContent(videoTitle);

    FileUploadProgressListener listener = new FileUploadProgressListener();
    ResumableGDataFileUploader uploader =
        new ResumableGDataFileUploader.Builder(
            service, new URL(RESUMABLE_UPLOAD_URL), ms, newEntry)
            .title(videoTitle)
            .trackProgress(listener, PROGRESS_UPDATE_INTERVAL)
            .chunkSize(DEFAULT_CHUNK_SIZE)
            .build();

    uploader.start();
    while (!uploader.isDone()) {
      Thread.sleep(PROGRESS_UPDATE_INTERVAL);
    }

    switch(uploader.getUploadState()) {
      case COMPLETE:
        output.println("Uploaded successfully");
        break;
      case CLIENT_ERROR:
        output.println("Upload Failed");
View Full Code Here

TOP

Related Classes of com.google.gdata.client.media.ResumableGDataFileUploader

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.