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


C# CloudBlockBlob.FetchAttributes方法代码示例

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


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

示例1: GetTitle

 protected String GetTitle(Uri blobURI)
 {
     //returns the title of the file from the Blob metadata
     CloudBlockBlob blob = new CloudBlockBlob(blobURI);
     blob.FetchAttributes();
     return blob.Metadata["Title"];
 }
开发者ID:crai9,项目名称:MP3-Shortener,代码行数:7,代码来源:Default.aspx.cs

示例2: revertFromSnapshot

        public void revertFromSnapshot(CloudBlockBlob blobRef, CloudBlockBlob snapshot)
        {
            try
            {

                    blobRef.StartCopyFromBlob(snapshot);
                    DateTime timestamp = DateTime.Now;
                    blobRef.FetchAttributes();
                    snapshot.FetchAttributes();
                    string time = snapshot.Metadata["timestamp"];
                    blobRef.Metadata["timestamp"] = timestamp.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss");
                    blobRef.SetMetadata();
                    blobRef.CreateSnapshot();
                    //System.Windows.Forms.MessageBox.Show("revert success");

                    Program.ClientForm.addtoConsole("Successfully Reverted with time: " + time);
                    Program.ClientForm.ballon("Successfully Reverted! ");

            }
            catch (Exception e)
            {
                Program.ClientForm.addtoConsole("Exception:" + e.Message);
                //System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:hangmiao,项目名称:DBLike,代码行数:25,代码来源:VCmanager.revert.cs

示例3: ArchiveOriginalPackageBlob

        /// <summary>
        /// Creates an archived copy of the original package blob if it doesn't already exist.
        /// </summary>
        private void ArchiveOriginalPackageBlob(CloudBlockBlob originalPackageBlob, CloudBlockBlob latestPackageBlob)
        {
            // Copy the blob to backup only if it isn't already successfully copied
            if ((!originalPackageBlob.Exists()) || (originalPackageBlob.CopyState != null && originalPackageBlob.CopyState.Status != CopyStatus.Success))
            {
                if (!WhatIf)
                {
                    Log.Info("Backing up blob: {0} to {1}", latestPackageBlob.Name, originalPackageBlob.Name);
                    originalPackageBlob.StartCopyFromBlob(latestPackageBlob);
                    CopyState state = originalPackageBlob.CopyState;

                    for (int i = 0; (state == null || state.Status == CopyStatus.Pending) && i < SleepTimes.Length; i++)
                    {
                        Log.Info("(sleeping for a copy completion)");
                        Thread.Sleep(SleepTimes[i]); 
                        originalPackageBlob.FetchAttributes(); // To get a refreshed CopyState

                        //refresh state
                        state = originalPackageBlob.CopyState;
                    }

                    if (state.Status != CopyStatus.Success)
                    {
                        string msg = string.Format("Blob copy failed: CopyState={0}", state.StatusDescription);
                        Log.Error("(error) " + msg);
                        throw new BlobBackupFailedException(msg);
                    }
                }
            }
        }
开发者ID:hermanocabral,项目名称:NuGetGallery,代码行数:33,代码来源:HandleQueuedPackageEditsTask.cs

示例4: GetInstanceIndex

 protected String GetInstanceIndex(Uri blobURI)
 {
     //returns the Worker role's index from the Blob metadata
     CloudBlockBlob blob = new CloudBlockBlob(blobURI);
     blob.FetchAttributes();
     return blob.Metadata["InstanceNo"];
 }
开发者ID:crai9,项目名称:MP3-Shortener,代码行数:7,代码来源:Default.aspx.cs

示例5: GetBlob

        public byte[] GetBlob(string containerName, string blobName)
        {
            CloudBlobContainer container = _blobClient.GetContainerReference(containerName);
            _blockBlob = container.GetBlockBlobReference(blobName);
            _blockBlob.FetchAttributes();

            long fileByteLength = _blockBlob.Properties.Length;
            byte[] fileContents = new byte[fileByteLength];
            _blockBlob.DownloadToByteArray(fileContents, 0);

            return fileContents;
        }
开发者ID:Lejdholt,项目名称:Muztache,代码行数:12,代码来源:BlobService.cs

示例6: Exists

 public static bool Exists(CloudBlockBlob blob)
 {
     try
     {
         blob.FetchAttributes();
         return true;
     }
     catch (StorageException)
     {
         return false;
     }
 }
开发者ID:kbastani,项目名称:predictive-autocomplete,代码行数:12,代码来源:BlobService.cs

示例7: BlobReadExpectLeaseSuccess

        /// <summary>
        /// Test blob reads, expecting success.
        /// </summary>
        /// <param name="testBlob">The blob to test.</param>
        /// <param name="testAccessCondition">The access condition to use.</param>
        private void BlobReadExpectLeaseSuccess(CloudBlockBlob testBlob, AccessCondition testAccessCondition)
        {
            testBlob.FetchAttributes(testAccessCondition, null /* options */);
            testBlob.Snapshot(null /* metadata */, testAccessCondition, null /* options */).Delete();
            DownloadText(testBlob, Encoding.UTF8, testAccessCondition, null /* options */);

            Stream stream = testBlob.OpenRead(testAccessCondition, null /* options */);
            stream.ReadByte();
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:14,代码来源:LeaseTests.cs

示例8: BlobReadExpectLeaseFailure

        /// <summary>
        /// Test blob reads, expecting lease failure.
        /// </summary>
        /// <param name="testBlob">The blob to test.</param>
        /// <param name="targetBlob">The blob to use for the target of copy operations.</param>
        /// <param name="testAccessCondition">The failing access condition to use.</param>
        /// <param name="expectedErrorCode">The expected error code.</param>
        /// <param name="description">The reason why these calls should fail.</param>
        private void BlobReadExpectLeaseFailure(CloudBlockBlob testBlob, CloudBlockBlob targetBlob, AccessCondition testAccessCondition, HttpStatusCode expectedStatusCode, string expectedErrorCode, string description)
        {
            // FetchAttributes is a HEAD request with no extended error info, so it returns with the generic ConditionFailed error code.
            TestHelper.ExpectedException(
                () => testBlob.FetchAttributes(testAccessCondition, null /* options */),
                description + "(Fetch Attributes)",
                HttpStatusCode.PreconditionFailed);

            TestHelper.ExpectedException(
                () => testBlob.Snapshot(null /* metadata */, testAccessCondition, null /* options */),
                description + " (Create Snapshot)",
                expectedStatusCode,
                expectedErrorCode);
            TestHelper.ExpectedException(
                () => DownloadText(testBlob, Encoding.UTF8, testAccessCondition, null /* options */),
                description + " (Download Text)",
                expectedStatusCode,
                expectedErrorCode);

            TestHelper.ExpectedException(
                () => testBlob.OpenRead(testAccessCondition, null /* options */),
                description + " (Read Stream)",
                expectedStatusCode/*,
                expectedErrorCode*/);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:33,代码来源:LeaseTests.cs

示例9: BlobWriteExpectLeaseSuccess

        /// <summary>
        /// Test blob writing, expecting success.
        /// </summary>
        /// <param name="testBlob">The blob to test.</param>
        /// <param name="sourceBlob">A blob to use as the source of a copy.</param>
        /// <param name="testAccessCondition">The access condition to use.</param>
        private void BlobWriteExpectLeaseSuccess(CloudBlockBlob testBlob, CloudBlob sourceBlob, AccessCondition testAccessCondition)
        {
            testBlob.SetMetadata(testAccessCondition, null /* options */);
            testBlob.SetProperties(testAccessCondition, null /* options */);
            UploadText(testBlob, "No Problem", Encoding.UTF8, testAccessCondition, null /* options */);
            testBlob.StartCopy(TestHelper.Defiddler(sourceBlob.Uri), null /* source access condition */, testAccessCondition, null /* options */);

            while (testBlob.CopyState.Status == CopyStatus.Pending)
            {
                Thread.Sleep(1000);
                testBlob.FetchAttributes();
            }

            Stream stream = testBlob.OpenWrite(testAccessCondition, null /* options */);
            stream.WriteByte(0);
            stream.Flush();

            testBlob.Delete(DeleteSnapshotsOption.None, testAccessCondition, null /* options */);
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:25,代码来源:LeaseTests.cs

示例10: ReadFromMetadata

        public AzurePackage ReadFromMetadata(CloudBlockBlob blob)
        {
            blob.FetchAttributes();
            var package = new AzurePackage();

            package.Id = blob.Metadata["Id"];
            package.Version = new SemanticVersion(blob.Metadata["Version"]);
            if (blob.Metadata.ContainsKey("Title"))
            {
                package.Title = blob.Metadata["Title"];
            }
            if (blob.Metadata.ContainsKey("Authors"))
            {
                package.Authors = blob.Metadata["Authors"].Split(',');
            }
            if (blob.Metadata.ContainsKey("Owners"))
            {
                package.Owners = blob.Metadata["Owners"].Split(',');
            }
            if (blob.Metadata.ContainsKey("IconUrl"))
            {
                package.IconUrl = new Uri(blob.Metadata["IconUrl"]);
            }
            if (blob.Metadata.ContainsKey("LicenseUrl"))
            {
                package.LicenseUrl = new Uri(blob.Metadata["LicenseUrl"]);
            }
            if (blob.Metadata.ContainsKey("ProjectUrl"))
            {
                package.ProjectUrl = new Uri(blob.Metadata["ProjectUrl"]);
            }
            package.RequireLicenseAcceptance = blob.Metadata["RequireLicenseAcceptance"].ToBool();
            package.DevelopmentDependency = blob.Metadata["DevelopmentDependency"].ToBool();
            if (blob.Metadata.ContainsKey("Description"))
            {
                package.Description = blob.Metadata["Description"];
            }
            if (blob.Metadata.ContainsKey("Summary"))
            {
                package.Summary = blob.Metadata["Summary"];
            }
            if (blob.Metadata.ContainsKey("ReleaseNotes"))
            {
                package.ReleaseNotes = blob.Metadata["ReleaseNotes"];
            }
            if (blob.Metadata.ContainsKey("Tags"))
            {
                package.Tags = blob.Metadata["Tags"];
            }
            var dependencySetContent = blob.Metadata["Dependencies"];
            dependencySetContent = this.Base64Decode(dependencySetContent);
            package.DependencySets = dependencySetContent
                .FromJson<IEnumerable<AzurePackageDependencySet>>()
                .Select(x => new PackageDependencySet(x.TargetFramework, x.Dependencies));
            package.IsAbsoluteLatestVersion = blob.Metadata["IsAbsoluteLatestVersion"].ToBool();
            package.IsLatestVersion = blob.Metadata["IsLatestVersion"].ToBool();
            if (blob.Metadata.ContainsKey("MinClientVersion"))
            {
                package.MinClientVersion = new Version(blob.Metadata["MinClientVersion"]);
            }
            package.Listed = blob.Metadata["Listed"].ToBool();

            return package;
        }
开发者ID:rjygraham,项目名称:Nuget.Server.AzureStorage,代码行数:64,代码来源:AzurePackageSerializer.cs

示例11: PrefixEscapingTest

        private void PrefixEscapingTest(string prefix, string blobName)
        {
            CloudBlobClient service = GenerateCloudBlobClient();
            CloudBlobContainer container = GetRandomContainerReference();

            try
            {
                container.Create();
                string text = Guid.NewGuid().ToString();

                // Create from CloudBlobContainer.
                CloudBlockBlob originalBlob = container.GetBlockBlobReference(prefix + "/" + blobName);
                originalBlob.PutBlockList(new string[] { });

                // List blobs from container. 
                IListBlobItem blobFromContainerListingBlobs = container.ListBlobs(null, true).First();
                Assert.AreEqual(originalBlob.Uri, blobFromContainerListingBlobs.Uri);

                // Check Name
                Assert.AreEqual<string>(prefix + "/" + blobName, originalBlob.Name);

                // Absolute URI access from CloudBlockBlob
                CloudBlockBlob blobInfo = new CloudBlockBlob(originalBlob.Uri, service.Credentials);
                blobInfo.FetchAttributes();

                // Access from CloudBlobDirectory
                CloudBlobDirectory cloudBlobDirectory = container.GetDirectoryReference(prefix);
                CloudBlockBlob blobFromCloudBlobDirectory = cloudBlobDirectory.GetBlockBlobReference(blobName);
                Assert.AreEqual(blobInfo.Uri, blobFromCloudBlobDirectory.Uri);

                // Copy blob verification.
                CloudBlockBlob copyBlob = container.GetBlockBlobReference(prefix + "/" + blobName + "copy");
                copyBlob.StartCopyFromBlob(blobInfo.Uri);
                copyBlob.FetchAttributes();
            }
            finally
            {
                container.Delete();
            }
        }
开发者ID:Juliako,项目名称:azure-sdk-for-net,代码行数:40,代码来源:EscapingTests.cs

示例12: DownloadBlobInParallel

 void DownloadBlobInParallel(CloudBlockBlob blob, Stream stream)
 {
     blob.FetchAttributes();
     blob.ServiceClient.ParallelOperationThreadCount = NumberOfIOThreads;
     container.ServiceClient.RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(BackOffInterval), MaxRetries);
     blob.DownloadToStream(stream);
     stream.Seek(0, SeekOrigin.Begin);
 }
开发者ID:jberke,项目名称:NServiceBus.Azure,代码行数:8,代码来源:BlobStorageDataBus.cs

示例13: DownloadBlob

        /// <summary>
        /// Downloads the BLOB.
        /// </summary>
        /// <param name="blob">The BLOB.</param>
        /// <param name="fetchAttribute">if set to <c>true</c> [fetch attribute].</param>
        /// <param name="metaData">The meta data.</param>
        /// <returns>System.Byte[].</returns>
        public static byte[] DownloadBlob(CloudBlockBlob blob, bool fetchAttribute, out IDictionary<string, string> metaData)
        {
            try
            {
                blob.CheckNullObject("blob");

                if (fetchAttribute)
                {
                    blob.FetchAttributes();
                    metaData = blob.Metadata;
                }
                else
                {
                    metaData = null;
                }

                var msRead = new MemoryStream { Position = 0 };
                using (msRead)
                {
                    blob.DownloadToStream(msRead);
                    return msRead.ToBytes();
                }
            }
            catch (Exception ex)
            {
                throw ex.Handle("DownloadBlob", blob.Uri.ToString());
            }
        }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:35,代码来源:AzureStorageManager.cs

示例14: IsBlobAged

 private static bool IsBlobAged(CloudBlockBlob blob, DateTime olderThanUtc)
 {
     try
     {
         blob.FetchAttributes();
         return blob.Properties.LastModified < olderThanUtc;
     }
     catch (StorageException e)
     {
         throw new BlobException(string.Format(CultureInfo.InvariantCulture, "Could not FetchAttributes or examine LastModified from properties for blob named '{0}' to see if it is aged older than '{1}' (UTC).  See inner exception for details.", blob.Name, olderThanUtc.ToString()), e);
     }
 }
开发者ID:modulexcite,项目名称:StudentSuccessDashboard,代码行数:12,代码来源:AzureBlobContainer.cs

示例15: DownloadBlobInParallel

 private void DownloadBlobInParallel(CloudBlockBlob blob, Stream stream)
 {
     try
     {
         blob.FetchAttributes();
         blob.ServiceClient.ParallelOperationThreadCount = NumberOfIOThreads;
         blob.DownloadToStream(stream);
         stream.Seek(0, SeekOrigin.Begin);
     }
     catch (StorageException ex)
     {
         logger.Warn(ex.Message);
     }
 }
开发者ID:afyles,项目名称:NServiceBus,代码行数:14,代码来源:BlobStorageDataBus.cs


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