本文整理汇总了C#中BlobRequestOptions类的典型用法代码示例。如果您正苦于以下问题:C# BlobRequestOptions类的具体用法?C# BlobRequestOptions怎么用?C# BlobRequestOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlobRequestOptions类属于命名空间,在下文中一共展示了BlobRequestOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: BlobReadStream
/// <summary>
/// Initializes a new instance of the BlobReadStream class.
/// </summary>
/// <param name="blob">The blob used for downloads.</param>
/// <param name="options">Modifiers to be applied to the blob. After first request, the ETag is always applied.</param>
/// <param name="readAheadInBytes">The number of bytes to read ahead.</param>
/// <param name="verifyBlocks">Controls whether block's signatures are verified.</param>
internal BlobReadStream(CloudBlob blob, BlobRequestOptions options, long readAheadInBytes, bool verifyBlocks)
{
CommonUtils.AssertNotNull("blob", blob);
CommonUtils.AssertNotNull("options", options);
CommonUtils.AssertInBounds("readAheadInBytes", readAheadInBytes, 0, Protocol.Constants.MaxBlobSize);
this.Blob = blob;
this.IntegrityControlVerificationEnabled = verifyBlocks;
this.options = options;
this.ReadAheadSize = readAheadInBytes;
this.downloadedBlocksList = new DownloadedBlockCollection();
}
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:BlobReadStream.cs
示例17: UploadBlock
public void UploadBlock(Stream input, long offset)
{
input.Seek(0, SeekOrigin.Begin);
string blockId = this.EncodeOffset(offset);
string contentMD5 = this.CalculateMD5(input);
var options = new BlobRequestOptions
{
RetryPolicy = RetryPolicies.RetryExponential(
RetryPolicies.DefaultClientRetryCount,
RetryPolicies.DefaultClientBackoff)
};
this.blob.PutBlock(blockId, input, contentMD5, options);
}
开发者ID:ShuHuiC,项目名称:BlobShare,代码行数:15,代码来源:DistributedUpload.cs
示例18: GetReferenceHashMap
public Dictionary<string, string> GetReferenceHashMap()
{
var output = new Dictionary<string, string>();
var options = new BlobRequestOptions();
options.UseFlatBlobListing = true;
foreach (var item in Container.ListBlobs(options)) {
//var reference = item.Uri.AbsolutePath.Substring(item.Uri.AbsolutePath.IndexOf('/', 1) + 1);
var blob = ((CloudBlob)item);
output[blob.Name] = blob.Properties.ContentMD5;
}
return output;
}
开发者ID:invertedtomato,项目名称:Amos2,代码行数:16,代码来源:BlobContainer.cs
示例19: BlobWriteStream
/// <summary>Initializes a new instance of the BlobWriteStream class.</summary>
/// <param name="blob">The blob used for uploads. </param>
/// <param name="options">The options used for the stream. </param>
/// <param name="blockSize">The size of the blocks to use. </param>
internal BlobWriteStream(CloudBlockBlob blob, BlobRequestOptions options, long blockSize)
{
CommonUtils.AssertNotNull("blob", blob);
CommonUtils.AssertNotNull("options", options);
this.Blob = blob;
this.blobHash = MD5.Create();
this.BlockSize = blockSize;
this.blockList = new List<string>();
this.currentModifier = options;
this.canWrite = true;
var rand = new Random();
this.blockIdSequenceNumber = (long)rand.Next() << 32;
this.blockIdSequenceNumber += rand.Next();
}
开发者ID:wforney,项目名称:azure-sdk-for-net,代码行数:20,代码来源:BlobWriteStream.cs
示例20: Mutex
// The mutex must already exists
public Mutex(CloudBlobContainer container, string mutexName, Exception e)
{
blob = container.GetBlobReference(mutexName);
byte[] b1 = { 1 };
BlobRequestOptions requestOpt = new BlobRequestOptions();
bool keepGoing = true;
string oldEtag = "";
int lastChange = 0;
do
{
byte[] b;
string eTag;
try
{
blob.FetchAttributes();
eTag = blob.Attributes.Properties.ETag;
if (eTag != oldEtag)
{
lastChange = Environment.TickCount;
oldEtag = eTag;
}
b = blob.DownloadByteArray();
}
catch (Exception)
{
throw e;
}
requestOpt.AccessCondition = AccessCondition.IfMatch(eTag);
if (b[0] == 0 || Environment.TickCount - lastChange > 3000) // on ne peut garder un lock plus de 3 s
{
try
{
blob.UploadByteArray(b1, requestOpt);
keepGoing = false;
}
catch (StorageClientException ex)
{
if (ex.ErrorCode != StorageErrorCode.ConditionFailed)
throw;
}
}
else
Thread.Sleep(50); // constante arbitraire
} while (keepGoing);
}
开发者ID:ismaelbelghiti,项目名称:Tigwi,代码行数:48,代码来源:Mutex.cs
注:本文中的BlobRequestOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论