コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: CloudMorph/CloudMorph
        protected void SignButton_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                this.InitializeStorage();

                // upload the image to blob storage
                string uniqueBlobName = string.Format("guestbookpics/image_{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileUpload1.FileName));
                string blobUri = _storage.AddToBucket("guestbookpics1", uniqueBlobName, this.FileUpload1.FileContent);
                System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", this.FileUpload1.FileName, uniqueBlobName);

                // create a new entry in table storage
                var entry = new GuestBookEntry() { GuestName = this.NameTextBox.Text, Message = this.MessageTextBox.Text, PhotoUrl = blobUri, ThumbnailUrl = blobUri };
                var ds = new GuestBookDataSource();
                ds.AddGuestBookEntry(entry);
                System.Diagnostics.Trace.TraceInformation("Added entry {0} in table storage for guest '{1}'", entry.Id, entry.GuestName);

                // queue a message to process the image
                var queue = _queue.GetQueueById("guestthumbs");
                var message = string.Format("{0},{1}", blobUri, entry.Id);
                _queue.SendMessage(queue, message);
                System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName);
            }

            this.NameTextBox.Text = string.Empty;
            this.MessageTextBox.Text = string.Empty;

            this.DataList1.DataBind();
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: eebesos/azurelab
        protected void SignButton_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                this.InitializeStorage();

                // upload the image to blob storage
                string uniqueBlobName = string.Format("guestbookpics/image_{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileUpload1.FileName));
                CloudBlockBlob blob = blobStorage.GetBlockBlobReference(uniqueBlobName);
                blob.Properties.ContentType = this.FileUpload1.PostedFile.ContentType;
                blob.UploadFromStream(this.FileUpload1.FileContent);
                System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", this.FileUpload1.FileName, uniqueBlobName);

                // create a new entry in table storage
                GuestBookEntry entry = new GuestBookEntry() { GuestName = this.NameTextBox.Text, Message = this.MessageTextBox.Text, PhotoUrl = blob.Uri.ToString(), ThumbnailUrl = blob.Uri.ToString() };
                GuestBookDataSource ds = new GuestBookDataSource();
                ds.AddGuestBookEntry(entry);
                System.Diagnostics.Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName);

                // queue a message to process the image
                var queue = queueStorage.GetQueueReference("guestthumbs");
                var message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri.ToString(), entry.PartitionKey, entry.RowKey));
                queue.AddMessage(message);
                System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName);

            }

            this.NameTextBox.Text = string.Empty;
            this.MessageTextBox.Text = string.Empty;

            this.DataList1.DataBind();
        }
コード例 #3
0
 private static void createNewEntryInCloudTableStorage(string name, string message, string uploadedFileBlobUri,
                                                       out string newEntryPartitionKey, out string newEntryRowKey)
 {
     var newGuestBookEntry = new GuestBookEntry
         {
             GuestName = name,
             Comment = message,
             PhotoUrl = uploadedFileBlobUri,
             ThumbnailUrl = uploadedFileBlobUri
         };
     var guestBookDataSource = new GuestBookDataSource();
     guestBookDataSource.AddGuestBookEntry(newGuestBookEntry);
     newEntryPartitionKey = newGuestBookEntry.PartitionKey;
     newEntryRowKey = newGuestBookEntry.RowKey;
     Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", newEntryPartitionKey,
                            newEntryRowKey, newGuestBookEntry.GuestName);
 }