當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudFile.FetchAttributesAsync方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.Storage.File.CloudFile.FetchAttributesAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudFile.FetchAttributesAsync方法的具體用法?C# CloudFile.FetchAttributesAsync怎麽用?C# CloudFile.FetchAttributesAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.Storage.File.CloudFile的用法示例。


在下文中一共展示了CloudFile.FetchAttributesAsync方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WaitForCopyAsync

 public static async Task WaitForCopyAsync(CloudFile file)
 {
     bool copyInProgress = true;
     while (copyInProgress)
     {
         await Task.Delay(1000);
         await file.FetchAttributesAsync();
         copyInProgress = (file.CopyState.Status == CopyStatus.Pending);
     }
 }
開發者ID:tamram,項目名稱:azure-storage-net,代碼行數:10,代碼來源:FileTestBase.cs

示例2: WaitForCopyTask

 public static void WaitForCopyTask(CloudFile file)
 {
     bool copyInProgress = true;
     while (copyInProgress)
     {
         Thread.Sleep(1000);
         file.FetchAttributesAsync().Wait();
         copyInProgress = (file.CopyState.Status == CopyStatus.Pending);
     }
 }
開發者ID:benaadams,項目名稱:azure-storage-net,代碼行數:10,代碼來源:FileTestBase.cs

示例3: FetchFileAttributesAsync

 public Task FetchFileAttributesAsync(CloudFile file, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
 {
     return file.FetchAttributesAsync(accessCondition, options, operationContext, token);
 }
開發者ID:Azure,項目名稱:azure-powershell,代碼行數:4,代碼來源:StorageFileManagement.cs

示例4: CloudFileSASSharedProtocolsQueryParamAsync

        public async Task CloudFileSASSharedProtocolsQueryParamAsync()
        {
            CloudFileShare share = GetRandomShareReference();
            try
            {
                await share.CreateAsync();
                CloudFile file;
                SharedAccessFilePolicy policy = new SharedAccessFilePolicy()
                {
                    Permissions = SharedAccessFilePermissions.Read,
                    SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
                    SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
                };

                CloudFile fileWithKey = share.GetRootDirectoryReference().GetFileReference("filefile");
                byte[] data = new byte[] { 0x1, 0x2, 0x3, 0x4 };
                byte[] target = new byte[4];
                await fileWithKey.UploadFromByteArrayAsync(data, 0, 4);

                foreach (SharedAccessProtocol? protocol in new SharedAccessProtocol?[] { null, SharedAccessProtocol.HttpsOrHttp, SharedAccessProtocol.HttpsOnly })
                {
                    string fileToken = fileWithKey.GetSharedAccessSignature(policy, null, null, protocol, null);
                    StorageCredentials fileSAS = new StorageCredentials(fileToken);
                    Uri fileSASUri = new Uri(fileWithKey.Uri + fileSAS.SASToken);
                    StorageUri fileSASStorageUri = new StorageUri(new Uri(fileWithKey.StorageUri.PrimaryUri + fileSAS.SASToken), new Uri(fileWithKey.StorageUri.SecondaryUri + fileSAS.SASToken));

                    int httpPort = fileSASUri.Port;
                    int securePort = 443;

                    if (!string.IsNullOrEmpty(TestBase.TargetTenantConfig.FileSecurePortOverride))
                    {
                        securePort = Int32.Parse(TestBase.TargetTenantConfig.FileSecurePortOverride);
                    }

                    var schemesAndPorts = new[] {
                        new { scheme = "HTTP", port = httpPort},
                        new { scheme = "HTTPS", port = securePort}
                    };

                    foreach (var item in schemesAndPorts)
                    {
                        fileSASUri = TransformSchemeAndPort(fileSASUri, item.scheme, item.port);
                        fileSASStorageUri = new StorageUri(TransformSchemeAndPort(fileSASStorageUri.PrimaryUri, item.scheme, item.port), TransformSchemeAndPort(fileSASStorageUri.SecondaryUri, item.scheme, item.port));

                        if (protocol.HasValue && protocol == SharedAccessProtocol.HttpsOnly && string.CompareOrdinal(item.scheme, "HTTP") == 0)
                        {
                            file = new CloudFile(fileSASUri);
                            OperationContext context = new OperationContext();
                            await TestHelper.ExpectedExceptionAsync(
                                async () => await file.FetchAttributesAsync(null /* accessCondition */, null /* options */, context),
                                context,
                                "Access a file using SAS with a shared protocols that does not match",
                                HttpStatusCode.Unused,
                                "");

                            file = new CloudFile(fileSASStorageUri, null);
                            context = new OperationContext();
                            await TestHelper.ExpectedExceptionAsync(
                                async () => await file.FetchAttributesAsync(null /* accessCondition */, null /* options */, context),
                                context,
                                "Access a file using SAS with a shared protocols that does not match",
                                HttpStatusCode.Unused,
                                "");
                        }
                        else
                        {
                            file = new CloudFile(fileSASUri);
                            await file.DownloadRangeToByteArrayAsync(target, 0, 0, 4, null, null, null);
                            for (int i = 0; i < 4; i++)
                            {
                                Assert.AreEqual(data[i], target[i]);
                            }

                            file = new CloudFile(fileSASStorageUri, null);
                            await file.DownloadRangeToByteArrayAsync(target, 0, 0, 4, null, null, null);
                            for (int i = 0; i < 4; i++)
                            {
                                Assert.AreEqual(data[i], target[i]);
                            }
                        }
                    }
                }
            }
            finally
            {
                share.DeleteIfExistsAsync().AsTask().Wait();
            }
        }
開發者ID:benaadams,項目名稱:azure-storage-net,代碼行數:88,代碼來源:FileSASTests.cs

示例5: StartAsyncCopy

        private async Task StartAsyncCopy(long taskId, CloudFile destFile, Func<bool> checkOverwrite, Func<Task<string>> startCopy)
        {
            bool destExist = true;
            try
            {
                await destFile.FetchAttributesAsync(null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken);
            }
            catch (StorageException ex)
            {
                if (!ex.IsNotFoundException())
                {
                    throw;
                }

                destExist = false;
            }

            if (!destExist || checkOverwrite())
            {
                string copyId = await startCopy();

                this.OutputStream.WriteVerbose(taskId, String.Format(Resources.CopyDestinationBlobPending, destFile.GetFullPath(), destFile.Share.Name, copyId));
                this.OutputStream.WriteObject(taskId, destFile);
            }
        }
開發者ID:docschmidt,項目名稱:azure-powershell,代碼行數:25,代碼來源:StartAzureStorageFileCopy.cs


注:本文中的Microsoft.WindowsAzure.Storage.File.CloudFile.FetchAttributesAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。