public void PutFile(BlobFileModel blobFileModel) { string blobFileName = string.Format("{0}_{1}", DateTime.Now.ToString("yyyy/MM/dd"), blobFileModel.FileName); // Upload the blob string blobUri = Blob.PutBlob(blobFileModel.BlobFile, blobFileName); // Add entry to table Table.Add( new MetaData { Description = blobFileModel.Description, Date = DateTime.Now, ImageURL = blobUri, RowKey = blobFileName }); // Add message to queue Queue.Add(new CloudQueueMessage(blobUri + "$" + blobFileName)); }
public ActionResult Upload() { foreach (string inputTagName in Request.Files) { var file = Request.Files[inputTagName]; if (file.ContentLength > 0) { var blobFileModel = new BlobFileModel { BlobFile = file.InputStream, Description = "I'll add a field for this.", DownloadedOn = DateTime.Now, FileName = Path.GetFileName(file.FileName) }; var repository = new FileBlobRepository(); repository.PutFile(blobFileModel); } } return RedirectToAction("Index", "Home"); }