Exemple #1
0
        // Convert Track1 Blob object to Track 2 blob Client
        public static BlobClient GetTrack2BlobClient(CloudBlob cloubBlob, AzureStorageContext context, BlobClientOptions options = null)
        {
            BlobClient blobClient;

            if (cloubBlob.ServiceClient.Credentials.IsToken) //Oauth
            {
                if (context == null)
                {
                    //TODO : Get Oauth context from current login user.
                    throw new System.Exception("Need Storage Context to convert Track1 Blob object in token credentail to Track2 Blob object.");
                }
                blobClient = new BlobClient(cloubBlob.SnapshotQualifiedUri, context.Track2OauthToken, options);
            }
            else if (cloubBlob.ServiceClient.Credentials.IsSAS) //SAS
            {
                string sas     = Util.GetSASStringWithoutQuestionMark(cloubBlob.ServiceClient.Credentials.SASToken);
                string fullUri = cloubBlob.SnapshotQualifiedUri.ToString();
                if (cloubBlob.IsSnapshot)
                {
                    // Since snapshot URL already has '?', need remove '?' in the first char of sas
                    fullUri = fullUri + "&" + sas;
                }
                else
                {
                    fullUri = fullUri + "?" + sas;
                }
                blobClient = new BlobClient(new Uri(fullUri), options);
            }
            else if (cloubBlob.ServiceClient.Credentials.IsSharedKey) //Shared Key
            {
                blobClient = new BlobClient(cloubBlob.SnapshotQualifiedUri,
                                            new StorageSharedKeyCredential(context.StorageAccountName, cloubBlob.ServiceClient.Credentials.ExportBase64EncodedKey()),
                                            options);
            }
            else //Anonymous
            {
                blobClient = new BlobClient(cloubBlob.SnapshotQualifiedUri, options);
            }

            return(blobClient);
        }
Exemple #2
0
 /// <summary>
 /// Get a service channel object using specified storage account
 /// </summary>
 /// <param name="account">Cloud storage account object</param>
 /// <returns>IStorageBlobManagement channel object</returns>
 protected IStorageBlobManagement CreateChannel(AzureStorageContext context)
 {
     return(new StorageBlobManagement(context));
 }
Exemple #3
0
        // Convert Track1 Blob object to Track 2 append blob Client
        public static AppendBlobClient GetTrack2AppendBlobClient(CloudBlob cloubBlob, AzureStorageContext context, BlobClientOptions options = null)
        {
            AppendBlobClient blobClient = (AppendBlobClient)Util.GetTrack2BlobClientWithType(
                AzureStorageBlob.GetTrack2BlobClient(cloubBlob, context, options),
                context,
                Track2blobModel.BlobType.Append,
                options);

            return(blobClient);
        }