本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.GetBlockBlobReference方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.GetBlockBlobReference方法的具体用法?C# CloudBlobContainer.GetBlockBlobReference怎么用?C# CloudBlobContainer.GetBlockBlobReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.StorageClient.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.GetBlockBlobReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFromBlob
public void CopyFromBlob(string destinationSasUri, string srcBlobSasUri)
{
CloudBlockBlob blob = new CloudBlockBlob(srcBlobSasUri);
string fileName = (blob.Name.Contains("/"))
? blob.Name.Substring(blob.Name.LastIndexOf("/"))
: blob.Name;
CloudBlobContainer cbc = new CloudBlobContainer(destinationSasUri);
//UriBuilder ub = new UriBuilder(destUri);
//ub.Path += "/" + fileName;
//CloudBlockBlob destBlob = new CloudBlockBlob(ub.Uri);
CloudBlockBlob destBlob = cbc.GetBlockBlobReference(fileName);
BlobRequestOptions bro = new BlobRequestOptions();
bro.RetryPolicy = RetryPolicies.RetryExponential(5, TimeSpan.FromMilliseconds(150));
destBlob.BeginCopyFromBlob(blob, bro, (result) => { }, null);
// destBlob.UploadFromStream(System.IO.File.OpenRead(@"D:\Install.txt"));
System.Diagnostics.Debug.WriteLine(destBlob.Name);
}
示例2: PutChunk
public void PutChunk(CloudBlobContainer container, string filename, int chunk, Stream inputStream)
{
var cloudBlockBlob = container.GetBlockBlobReference(filename);
var blockId = Convert.ToBase64String(Encoding.UTF8.GetBytes("chk_" + chunk.ToString("D8")));
cloudBlockBlob.PutBlock(blockId, inputStream, null);
}
示例3: UploadDataFileToBlobStorage
//----------------------------------------------------------------------
// ToDo.UploadDataFileToBlobStorage
//
// Input : fileContent - input stream of the file to be uploaded
// blobContainer - blob container in which the file stored
// Return : name of Blob file created in Azure blob storage
// Purpose : Upload a local data file to Azure blob storage
// Note :
//
// * To upload a file to blob storage:
//
// CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blobAddressUri);
// blob.UploadFromStream(fileContent);
//----------------------------------------------------------------------
public static string UploadDataFileToBlobStorage(Stream fileContent, CloudBlobContainer blobContainer)
{
CloudBlockBlob blob = blobContainer.GetBlockBlobReference(ToDo.blobAddressUri);
blob.UploadFromStream(fileContent);
return ToDo.blobAddressUri;
}
示例4: initialize
/* format device */
public void initialize(string id)
{
/* file system already initialized, return ASAP */
if (_initialized == true)
{
return;
}
/*
* no need to synchronize,
* since when intialize the file system, only one process/thread
* is active
*/
try
{
Microsoft.WindowsAzure.CloudStorageAccount.
SetConfigurationSettingPublisher(
(configName, configSetter) =>
{
configSetter(RoleEnvironment.
GetConfigurationSettingValue(configName));
}
);
var storageAccount =
CloudStorageAccount.FromConfigurationSetting(
"DataConnectionString");
var client = storageAccount.CreateCloudBlobClient();
/* get root path, create if not exists */
var user_container = client.GetContainerReference("user");
var blob = user_container.GetBlobReference("user/container/"+id);
_rootPath = client.GetContainerReference(blob.DownloadText());
_rootPath.CreateIfNotExist();
Stream root = new MemoryStream();
var root_blob = _rootPath.GetBlockBlobReference("/");
root_blob.Properties.ContentType = AFS_BINARY_MODE;
root_blob.UploadFromStream(root);
root.Close();
// CloudBlockBlob blob = _rootPath.GetBlockBlobReference("a/");
// blob.Properties.ContentType = "application/octet-stream";
// Stream a = new MemoryStream();
// blob.UploadFromStream(a);
// a.Close();
/* create root node */
_rootNode = new AzureFileSystemNode(null, AFS_ROOT,
NodeType.DIRECTORY);
}
catch (WebException e)
{
System.Diagnostics.Trace.TraceError(
"An error occurs while intializing Azure file system. {0}",
e.Message);
}
_initialized = true;
System.Diagnostics.Trace.TraceInformation(
"Azure file system format complete!");
}
示例5: LoadFollowerTableFromBlob
//----------------------------------------------------------------------
// ToDo.LoadFollowerTableFromBlob
//
// Input : blobContainer - blob container which has data file we uploaded
// followerTable - empty follower table
// Return : Number of inserted entries (records) into follower table
// Purpose : Load followerTable with follower entries which are composed from blob object
// Note :
//
// * To read a blob file line by line:
//
// StreamReader sr = new StreamReader(blobContainer.GetBlobReference(BlobAddressUri).OpenRead());
// String line;
// while ((line = sr.ReadLine()) != null)
// { ...
//
// * Format of the line of input data:
//
// user_id \t follower_id
//
// * To insert an entry to follower table:
//
// followerTable.AddFollowerEntry(new FollowerEntry(userID, followerID, partitionKey));
// followerTable.SaveChanges();
//----------------------------------------------------------------------
public static int LoadFollowerTableFromBlob(CloudBlobContainer blobContainer, FollowerEntryDataSource followerTable)
{
int numFollowerEntries = 0;
StreamReader sr = new StreamReader(blobContainer.GetBlockBlobReference(ToDo.blobAddressUri).OpenRead());
String line;
while ((line = sr.ReadLine()) != null)
{
numFollowerEntries++;
String [] split = line.Split(new Char [] {'\t'});
int User = Convert.ToInt32(split[0]);
int Follower = Convert.ToInt32(split[1]);
// Partition Key = (User + Follower) % #(Worker Role Instances)
// Users who are mutually friends to each other are contained in the same partition
string PartitionKey = ((User + Follower) % ToDo.NumWorkerRoleInstances).ToString();
followerTable.AddFollowerEntry(new FollowerEntry(User, Follower, PartitionKey));
followerTable.SaveChages();
}
return numFollowerEntries;
}