当前位置: 首页>>代码示例>>C#>>正文


C# Flickr.UploadPictureAsync方法代码示例

本文整理汇总了C#中FlickrNet.Flickr.UploadPictureAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Flickr.UploadPictureAsync方法的具体用法?C# Flickr.UploadPictureAsync怎么用?C# Flickr.UploadPictureAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlickrNet.Flickr的用法示例。


在下文中一共展示了Flickr.UploadPictureAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteUpload

		protected void ExecuteUpload(IExecuteFlickrUploaderWorkflowMessage message, Flickr flickr, FileInfo inputFilePath)
		{
			var cancellationTokenSource = new CancellationTokenSource();
			var cancellationToken = cancellationTokenSource.Token;

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

                    var asyncUploadSettings = new AsyncUploadSettings
                    {
                        Message = message,
                        InputStream = inputFilePath.OpenRead()
                    };

				    var uploader = new Uploader(asyncUploadSettings);

                    flickr.OnUploadProgress += uploader.OnUploadProgress;

                    flickr.UploadPictureAsync(asyncUploadSettings.InputStream, inputFilePath.Name,
                                message.Settings.MetaData.Title,
                                message.Settings.MetaData.Description,
                                message.Settings.MetaData.Keywords,
                                message.Settings.MetaData.IsPublic,
                                message.Settings.MetaData.IsFamily,
                                message.Settings.MetaData.IsFriend,
                                message.Settings.MetaData.ContentType,
                                message.Settings.MetaData.SafetyLevel,
                                message.Settings.MetaData.HiddenFromSearch, 
                                result =>
                                    {
                                        FlickrUploaderService.Uploaders.Remove(message);
                                        uploader.OnUploadCompleted(result);
                                    } 
                                );
				}
				cancellationToken.ThrowIfCancellationRequested();
			}
				, cancellationToken);
		}
开发者ID:taliesins,项目名称:talifun-commander,代码行数:47,代码来源:ExecuteFlickrUploaderWorkflowMessageHandlerBase.cs


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