InsertAsync() public method

public InsertAsync ( Authenticator authentication, AbstractEntry payload, object userData ) : void
authentication Authenticator
payload AbstractEntry
userData object
return void
		protected void ExecuteUpload(IExecutePicasaUploaderWorkflowMessage message, ClientLoginAuthenticator picasaAuthenticator, PicasaEntry picasaEntry)
		{
			var cancellationTokenSource = new CancellationTokenSource();
			var cancellationToken = cancellationTokenSource.Token;

			var task = Task.Factory.StartNew(()=>{});
			task.ContinueWith((t) =>
				{
					if (!cancellationToken.IsCancellationRequested)
					{
						PicasaUploaderService.Uploaders.Add(message, new CancellableTask
						{
							Task = task,
							CancellationTokenSource = cancellationTokenSource
						});

						var resumableUploader = new ResumableUploader(message.Settings.Upload.ChunkSize);

						resumableUploader.AsyncOperationCompleted += OnResumableUploaderAsyncOperationCompleted;
						resumableUploader.AsyncOperationProgress += OnResumableUploaderAsyncOperationProgress;

						cancellationToken.Register(() => resumableUploader.CancelAsync(message));
						resumableUploader.InsertAsync(picasaAuthenticator, picasaEntry, message);
					}
					cancellationToken.ThrowIfCancellationRequested();
				}
				, cancellationToken);
		}
コード例 #2
0
    public async Task UploadToYouTube(HttpPostedFile postedFile, string title)
    {
        UploadingDispatcher.SetProgress(uploadId, 2);
        Video video = new Video();
        video.Title = title;
        video.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
        video.Private = false;
        video.MediaSource = new MediaFileSource(postedFile.InputStream, postedFile.FileName, postedFile.ContentType);

        var link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads");
        link.Rel = ResumableUploader.CreateMediaRelation;
        video.YouTubeEntry.Links.Add(link);

        var youtubeApiKey = ConfigurationManager.AppSettings["youtubeApiKey"];
        var applicationName = ConfigurationManager.AppSettings["applicationName"];
        var youtubeUserName = ConfigurationManager.AppSettings["youtubeUserName"];
        var youtubePassword = ConfigurationManager.AppSettings["youtubePassword"];
        var youtubeChunksize = int.Parse(ConfigurationManager.AppSettings["youtubeChunksize"]);

        var resumableUploader = new ResumableUploader(youtubeChunksize); 
        resumableUploader.AsyncOperationCompleted += resumableUploader_AsyncOperationCompleted;
        resumableUploader.AsyncOperationProgress += resumableUploader_AsyncOperationProgress;

      
        var youTubeAuthenticator = new ClientLoginAuthenticator(applicationName, ServiceNames.YouTube, youtubeUserName, youtubePassword);
        youTubeAuthenticator.DeveloperKey = youtubeApiKey;

        resumableUploader.InsertAsync(youTubeAuthenticator, video.YouTubeEntry, uploadId);
    }
コード例 #3
0
ファイル: Google2u.cs プロジェクト: joenarus/Stressident
        public void DoWorkbookUpload(object in_instance)
        {
            var instance = in_instance as Google2uData;
            if (instance == null)
                return;

            if (!string.IsNullOrEmpty(instance.WorkbookUploadPath))
            {
                try
                {
                    // We need a DocumentService
                    var service = new DocumentsService("Google2Unity");
                    var mimeType = Google2uMimeType.GetMimeType(instance.WorkbookUploadPath);

                    var authenticator = new OAuth2Authenticator("Google2Unity", _authParameters);

                    // Instantiate a DocumentEntry object to be inserted.
                    var entry = new DocumentEntry
                    {
                        MediaSource = new MediaFileSource(instance.WorkbookUploadPath, mimeType)
                    };

                    // Define the resumable upload link
                    var createUploadUrl =
                        new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
                    var link = new AtomLink(createUploadUrl.AbsoluteUri)
                    {
                        Rel = ResumableUploader.CreateMediaRelation
                    };

                    entry.Links.Add(link);

                    // Set the service to be used to parse the returned entry
                    entry.Service = service;


                    // Instantiate the ResumableUploader component.
                    var uploader = new ResumableUploader();

                    // Set the handlers for the completion and progress events
                    uploader.AsyncOperationCompleted += OnSpreadsheetUploadDone;
                    uploader.AsyncOperationProgress += OnSpreadsheetUploadProgress;

                    // Start the upload process
                    uploader.InsertAsync(authenticator, entry, instance);
                }
                catch (Exception)
                {
                    PushNotification(
                        "There is a problem with your credentials. Clear the credentials and Re-Authorize G2U");
                    //instance.Messages.Add(new G2GUIMessage(GFGUIMessageType.InvalidLogin, ex.Message));
                    instance.Commands.Remove(GFCommand.WaitingForUpload);
                }
            }
        }
コード例 #4
0
 public static void CreateGoogleNote(/*Document parentFolder, */Document googleNote, object UserData, DocumentsRequest documentsRequest, ResumableUploader uploader, OAuth2Authenticator authenticator)
 {
     // Define the resumable upload link
     Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
     //Uri createUploadUrl = new Uri(GoogleNotesFolder.AtomEntry.EditUri.ToString());
     AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri);
     link.Rel = ResumableUploader.CreateMediaRelation;
     googleNote.DocumentEntry.Links.Add(link);
     //if (parentFolder != null)
     //    googleNote.DocumentEntry.ParentFolders.Add(new AtomLink(parentFolder.DocumentEntry.SelfUri.ToString()));
     // Set the service to be used to parse the returned entry
     googleNote.DocumentEntry.Service = documentsRequest.Service;
     // Start the upload process
     //uploader.InsertAsync(_authenticator, match.GoogleNote.DocumentEntry, new object());
     uploader.InsertAsync(authenticator, googleNote.DocumentEntry, UserData);
 }