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


C# BlobRequestOptions类代码示例

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


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

示例1: GetTarget_BatchToProcess

        public static CloudBlockBlob[] GetTarget_BatchToProcess(int processBatchSize, bool processIfLess)
        {
            //options.
            //options.AccessCondition
            //StorageSupport.CurrActiveContainer.ListBlobsSegmented()
            //    ListBlobsWithPrefix("sys/AAA/TheBall.CORE/RequestResourceUsage")
            string prefix = "sys/AAA/TheBall.CORE/RequestResourceUsage/";

            BlobRequestOptions options = new BlobRequestOptions {UseFlatBlobListing = true};
            var blobList = StorageSupport.CurrActiveContainer.ListBlobxWithPrefixSegmented(prefix, processBatchSize, null, options);
            List<CloudBlockBlob> result = new List<CloudBlockBlob>();
            foreach (var blobListItem in blobList.Results)
            {
                CloudBlockBlob blob = (CloudBlockBlob) blobListItem;
                if (blob.Name == LockLocation)
                    return null;
                result.Add(blob);
            }
            if (result.Count < processBatchSize && processIfLess == false)
                return null;
            // Acquire Lock
            string lockETag;
            bool acquiredLock = StorageSupport.AcquireLogicalLockByCreatingBlob(LockLocation, out lockETag);
            if (!acquiredLock)
                return null;
            return result.ToArray();
        }
开发者ID:kallex,项目名称:Caloom,代码行数:27,代码来源:ProcessBatchOfResourceUsagesToOwnerCollectionsImplementation.cs

示例2: UploadPackageToBlob

        public static Uri UploadPackageToBlob(IServiceManagement channel, string storageName, string subscriptionId, string packagePath, BlobRequestOptions blobRequestOptions)
        {
            StorageService storageService = channel.GetStorageKeys(subscriptionId, storageName);
            string storageKey = storageService.StorageServiceKeys.Primary;

            return UploadFile(storageName, storageKey, packagePath, blobRequestOptions);
        }
开发者ID:nicopeelen,项目名称:azure-sdk-tools,代码行数:7,代码来源:AzureBlob.cs

示例3: DeletePhotoBlob

        public static bool DeletePhotoBlob(Guid photoId)
        {
            try
            {
                // Delete from Azure
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                    ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                // Get a reference to the container.
                CloudBlobContainer container = blobClient.GetContainerReference("photos");

                // Indicate that any snapshots should be deleted.
                BlobRequestOptions options = new BlobRequestOptions();
                options.DeleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots;

                // Specify a flat blob listing, so that only CloudBlob objects will be returned.
                // The Delete method exists only on CloudBlob, not on IListBlobItem.
                options.UseFlatBlobListing = true;

                var blob = container.GetBlobReference(photoId.ToString());

                blob.Delete(options);

                return true;
            }
            catch
            {
            }

            return false;
        }
开发者ID:benjyblack,项目名称:chwinock,代码行数:33,代码来源:Utilities.cs

示例4: Get

		public IBlob Get(Uri uri)
		{
			IBlob blob = null;

			var options = new BlobRequestOptions { BlobListingDetails = BlobListingDetails.Metadata };

			var container = getContainer();
			var target = container.GetBlobReference(uri.ToString());

			try
			{
				target.FetchAttributes();
				blob = new Blob(target.Properties.ContentMD5, target.Properties.ETag)
					{ Content = target.DownloadByteArray(), ContentType = target.Properties.ContentType, };

				foreach (var key in target.Metadata.AllKeys)
				{
					blob.Metdata.Add(new KeyValuePair<string, string>(key, target.Metadata[key]));
				}
			}
			catch (StorageClientException s)
			{
				this.WriteErrorMessage(string.Format("An error occurred retrieving the blob from {0}", uri), s);
				blob = null;
			}

			return blob;
		}
开发者ID:smhinsey,项目名称:Euclid,代码行数:28,代码来源:AzureBlobStorage.cs

示例5: Read

        public static void Read(BlobRequestOptions mapped, CloudBlob blob, ReaderDelegate reader)
        {
            blob.FetchAttributes(mapped);
            var props = MapFetchedAttrbitues(blob);

            var compression = blob.Properties.ContentEncoding ?? "";
            var md5 = blob.Metadata[LokadHashFieldName];

            switch (compression)
            {
                case "gzip":
                    using (var stream = blob.OpenRead(mapped))
                    {
                        ReadAndVerifyHash(stream, s =>
                            {
                                // important is not to flush the decompression stream
                                using (var decompress = new GZipStream(s, CompressionMode.Decompress, true))
                                {
                                    reader(props, decompress);
                                }
                            }, md5);
                    }

                    break;
                case "":
                    using (var stream = blob.OpenRead(mapped))
                    {
                        ReadAndVerifyHash(stream, s => reader(props, s), md5);
                    }
                    break;
                default:
                    var error = string.Format("Unsupported ContentEncoding '{0}'", compression);
                    throw new InvalidOperationException(error);
            }
        }
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:35,代码来源:BlobStorageUtil.cs

示例6: ParallelUpload

        public static void ParallelUpload(this CloudBlockBlob blobRef, string filename, BlobRequestOptions options)
        {
            if (null == options)
            {
                options = new BlobRequestOptions()
                {
                    Timeout = blobRef.ServiceClient.Timeout,
                    RetryPolicy = RetryPolicies.RetryExponential(RetryPolicies.DefaultClientRetryCount, RetryPolicies.DefaultClientBackoff)
                };
            }

            // get upload history if any
            UploadInfo uploadInfo = UploadInfo.LoadByUploadFilename(filename);

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                blobRef.ParallelUpload(fs, uploadInfo, options);
            }

            // upload completed no history needed - delete it
            if (File.Exists(uploadInfo.LogFilename))
                File.Delete(uploadInfo.LogFilename);

            Console.WriteLine("\nUpload completed.");
        }
开发者ID:michaelwiles,项目名称:AzureCommandLineTools,代码行数:25,代码来源:BlobExtensions.cs

示例7: GetAll

        public static List<BlobHelper> GetAll(string container, string account, string key)
        {
            List<BlobHelper> list = new List<BlobHelper>();
            CloudBlobContainer cont = StorageHelper.Container.Get(account,key, container);

            if (cont == null)
                return list;

            BlobRequestOptions opt = new BlobRequestOptions();
            opt.BlobListingDetails = BlobListingDetails.All;
            opt.UseFlatBlobListing = true;

            foreach (IListBlobItem blob in cont.ListBlobs(opt))
            {
                CloudBlockBlob b = blob as CloudBlockBlob;
                if (b == null)
                    continue;

                b.FetchAttributes(opt);

                BlobHelper bh = new BlobHelper();
                bh.Url = b.Uri.ToString();
                bh.Name = b.Uri.Segments[b.Uri.Segments.Length - 1];
                bh.Size = b.Properties.Length;
                bh.Type = b.Properties.ContentType;
                bh.BlobType = b.Properties.BlobType.ToString();
                bh.LastModfied = b.Properties.LastModifiedUtc;
                bh.ETag = b.Properties.ETag;
                list.Add(bh);
            }

            return list;
        }
开发者ID:nagyistoce,项目名称:azurestorageexplorer,代码行数:33,代码来源:BlobHelper.cs

示例8: GetBlobContainer

        public static async Task<CloudBlobContainer> GetBlobContainer(string containerName)
        {
            if (String.IsNullOrEmpty(containerName))
            {
                throw new ArgumentException("containerName");
            }

            // Retrieve storage account from connection-string
            string connectionString = CloudConfigurationManager.GetSetting("CloudStorageConnectionString");
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

            // Create the blob client 
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container. Note that container name must use lower case
            CloudBlobContainer container = blobClient.GetContainerReference(containerName.ToLowerInvariant());

            // Create options for communicating with the blob container.
            BlobRequestOptions options = new BlobRequestOptions();

            // Create the container if it doesn't already exist
            bool result = await Task.Factory.FromAsync<BlobRequestOptions, bool>(container.BeginCreateIfNotExist, container.EndCreateIfNotExist, options, state: null);

            // Enable public access to blob
            BlobContainerPermissions permissions = container.GetPermissions();
            if (permissions.PublicAccess == BlobContainerPublicAccessType.Off)
            {
                permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
                container.SetPermissions(permissions);
            }

            return container;
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:33,代码来源:BlobHelper.cs

示例9: UploadFile

        /// <summary>
        /// Uploads a file to azure store.
        /// </summary>
        /// <param name="storageName">Store which file will be uploaded to</param>
        /// <param name="storageKey">Store access key</param>
        /// <param name="filePath">Path to file which will be uploaded</param>
        /// <param name="blobRequestOptions">The request options for blob uploading.</param>
        /// <returns>Uri which holds locates the uploaded file</returns>
        /// <remarks>The uploaded file name will be guid</remarks>
        public static Uri UploadFile(string storageName, string storageKey, string filePath, BlobRequestOptions blobRequestOptions)
        {
            string baseAddress = General.BlobEndpointUri(storageName);
            var credentials = new StorageCredentialsAccountAndKey(storageName, storageKey);
            var client = new CloudBlobClient(baseAddress, credentials);
            string blobName = Guid.NewGuid().ToString();

            CloudBlobContainer container = client.GetContainerReference(ContainerName);
            container.CreateIfNotExist();
            CloudBlob blob = container.GetBlobReference(blobName);

            using (FileStream readStream = File.OpenRead(filePath))
            {
                blob.UploadFromStream(readStream, blobRequestOptions);
            }

            return new Uri(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}{1}{2}{3}",
                    client.BaseUri,
                    ContainerName,
                    client.DefaultDelimiter,
                    blobName));
        }
开发者ID:nicopeelen,项目名称:azure-sdk-tools,代码行数:34,代码来源:AzureBlob.cs

示例10: UploadPackageToBlob

        public static Uri UploadPackageToBlob(IServiceManagement channel, string storageName, string subscriptionId, string packagePath, BlobRequestOptions blobRequestOptions)
        {
            StorageService storageService = channel.GetStorageKeys(subscriptionId, storageName);
            string storageKey = storageService.StorageServiceKeys.Primary;
            storageService = channel.GetStorageService(subscriptionId, storageName);
            string blobEndpointUri = storageService.StorageServiceProperties.Endpoints[0];

            return UploadFile(storageName, CreateHttpsEndpoint(blobEndpointUri), storageKey, packagePath, blobRequestOptions);
        }
开发者ID:bueti,项目名称:azure-sdk-tools,代码行数:9,代码来源:AzureBlob.cs

示例11: UploadFile

 public static Uri UploadFile(
     string storageName,
     Uri blobEndpointUri,
     string storageKey,
     string filePath,
     BlobRequestOptions blobRequestOptions)
 {
     return cloudBlobUtility.UploadFile(storageName, blobEndpointUri, storageKey, filePath, blobRequestOptions);
 }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:9,代码来源:AzureBlob.cs

示例12: XStoreExperiment

 public XStoreExperiment(Guid experimentId, CloudBlobClient client, string title, int requestedIterations, string instanceId)
     : base(experimentId, title, requestedIterations, instanceId)
 {
     this.instanceId = instanceId;
     this.client = client;
     this.requestOptions = new BlobRequestOptions
     {
         RetryPolicy = TrackedPolicy,
         Timeout = TimeSpan.FromMinutes(5),
     };
 }
开发者ID:w7cf,项目名称:cloudBench,代码行数:11,代码来源:XStoreExperiment.cs

示例13: ParallelUpload

 /// <summary>Initializes a new instance of the <see cref="ParallelUpload"/> class.</summary>
 /// <param name="source">The source stream. </param>
 /// <param name="options">The request options. </param>
 /// <param name="blockSize">The block size to use. </param>
 /// <param name="blob">The blob to upload to. </param>
 internal ParallelUpload(Stream source, BlobRequestOptions options, long blockSize, CloudBlockBlob blob)
 {
     this.sourceStream = source;
     this.blockSize = blockSize;
     this.options = options;
     this.dispensizedStreamSize = 0;
     this.blob = blob;
     this.blobHash = MD5.Create();
     this.blockList = new List<string>();
     this.parellelism = this.GetParallelismFactor();
 }
开发者ID:wforney,项目名称:azure-sdk-for-net,代码行数:16,代码来源:ParallelUpload.cs

示例14: UploadPackageToBlob

 public static Uri UploadPackageToBlob(
     StorageManagementClient storageClient,
     string storageName,
     string packagePath,
     BlobRequestOptions blobRequestOptions)
 {
     return cloudBlobUtility.UploadPackageToBlob(
         storageClient,
         storageName,
         packagePath,
         blobRequestOptions);
 }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:12,代码来源:AzureBlob.cs

示例15: GetWebRequest

        /// <summary>
        /// Gets the web request.
        /// </summary>
        /// <param name="serviceClient">The service client.</param>
        /// <param name="options">The options.</param>
        /// <param name="retrieveRequest">The retrieve request.</param>
        /// <returns>The web request.</returns>
        internal static HttpWebRequest GetWebRequest(CloudBlobClient serviceClient, BlobRequestOptions options, Func<int, HttpWebRequest> retrieveRequest)
        {
            CommonUtils.AssertNotNull("options", options);

            int timeoutInSeconds = options.Timeout.RoundUpToSeconds();
            AccessCondition accessCondition = options.AccessCondition;

            var webRequest = retrieveRequest(timeoutInSeconds);
            accessCondition.ApplyCondition(webRequest);
            CommonUtils.ApplyRequestOptimizations(webRequest, -1);

            return webRequest;
        }
开发者ID:rmarinho,项目名称:azure-sdk-for-net,代码行数:20,代码来源:ProtocolHelper.cs


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