using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Blob; using Microsoft.WindowsAzure.Storage.Auth;
// Create the connectionstring String StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=[yourAccount];AccountKey=[yourKey]";
// Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(StorageConnectionString);
// Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { // Create the connectionstring String StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=[yourAccount];AccountKey=[yourKey]"; // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(StorageConnectionString); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve a reference to a container. (pictures) CloudBlobContainer container1 = blobClient.GetContainerReference("pictures"); await container1.CreateIfNotExistsAsync(); // Retrieve a reference to a container. (pictures) CloudBlobContainer container2 = blobClient.GetContainerReference("movies"); await container2.CreateIfNotExistsAsync(); } }
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { // Create the connectionstring String StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=[yourAccount];AccountKey=[yourKey]"; // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(StorageConnectionString); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference("pictures"); FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add(".jpg"); picker.SuggestedStartLocation = PickerLocationId.Desktop; picker.ViewMode = PickerViewMode.Thumbnail; StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read)) { // Retrieve reference to a blob named CloudBlockBlob blockBlob = container.GetBlockBlobReference(file.Name); await blockBlob.UploadFromStreamAsync(fileStream); } } } }
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { // Create the connectionstring String StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=[yourAccount];AccountKey=[yourKey]"; // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(StorageConnectionString); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference("pictures"); // Variable for parameters. BlobContinuationToken continuationToken = null; string prefix = null; bool useFlatBlobListing = true; BlobListingDetails blobListingDetails = BlobListingDetails.All; int maxBlobsPerRequest = 10; List<IListBlobItem> blobs = new List<IListBlobItem>(); // Get list item blob. var listingResult = await container.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, maxBlobsPerRequest, continuationToken, null, null); continuationToken = listingResult.ContinuationToken; blobs.AddRange(listingResult.Results); // Display blob item foreach (IListBlobItem item in blobs) { if (item.GetType() == typeof(CloudBlockBlob)) { CloudBlockBlob blob = (CloudBlockBlob)item; // blob.Properties.Length + " - " + blob.Uri this.lblResult.Text = this.lblResult.Text + blob.Properties.Length + " - " + blob.Uri + Environment.NewLine; } } } }
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { // Create the connectionstring String StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=[yourAccount];AccountKey=[yourKey]"; // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(StorageConnectionString); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference("pictures"); // Retrieve reference to a blob named CloudBlockBlob blockBlob = container.GetBlockBlobReference("deawx.jpg"); // Delete the blob. await blockBlob.DeleteAsync(); } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท