private void UploadFiletoBlob(HttpPostedFileBase file) { StorageCredentials cred = new StorageCredentials(BlobAccountName, BlobAccessKey); CloudStorageAccount acc = new CloudStorageAccount(cred, true); CloudBlobClient client = acc.CreateCloudBlobClient(); CloudBlobContainer container = client.GetContainerReference("images"); container.CreateIfNotExists(); container.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob }); CloudBlockBlob blob = container.GetBlockBlobReference(file.FileName); using (Stream stream = file.InputStream) { blob.Properties.ContentType = file.ContentType; blob.UploadFromStream(stream); } Face face = new Face(); face.filename = file.FileName; face.name = "face"; using (var ctx = new facedbEntities()) { ctx.Faces.Add(face); ctx.SaveChanges(); } }
private void UploadFiles(HttpPostedFileBase file) { string filename = file.FileName; string imageLocation = HttpContext.Server.MapPath("~/Images/"); file.SaveAs(imageLocation + filename); Face face = new Face(); face.filename = filename; face.name = "face"; using (var ctx = new facedbEntities()) { ctx.Faces.Add(face); ctx.SaveChanges(); } }