public void uploadFile()
        {
            if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
            {
                var httpPostedFile = System.Web.HttpContext.Current.Request.Files["image"];
                if (httpPostedFile != null)
                {
                    var fileSavePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content"), httpPostedFile.FileName);
                    httpPostedFile.SaveAs(fileSavePath);
                    var            blobPath  = Path.Combine(User.Identity.GetUserName(), BlobStorage.IsImage(httpPostedFile), httpPostedFile.FileName);
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobPath);
                    using (var fileStream = System.IO.File.OpenRead(fileSavePath))
                    {
                        blockBlob.UploadFromStream(fileStream);
                    }

                    FileNote newFile = new FileNote();
                    newFile.UserId      = User.Identity.GetUserId();
                    newFile.AspNetUsers = db.AspNetUsers.SingleOrDefault(e => e.Id == newFile.UserId);
                    newFile.Url         = Path.Combine(container.Uri.ToString(), blobPath);
                    newFile.Name        = httpPostedFile.FileName;
                    newFile.CreatedAt   = System.DateTime.Now;
                    newFile.Type        = BlobStorage.IsImage(httpPostedFile);
                    db.FileNotes.Add(newFile);
                    db.SaveChanges();

                    System.IO.File.Delete(fileSavePath);
                }
            }
        }
Beispiel #2
0
        public ActionResult getFuleNoteById(string fileNoteId)
        {
            documentService = new DocumentService();
            FileNote fileNote = new FileNote();

            fileNote = documentService.GetFileNoteById(fileNoteId);
            return(Json(fileNote, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
 private void LoadFileNote(string path, IdeaNote parent, int index)
 {
     FileNote newNote = new FileNote();
     newNote.FileName = path;
     AddNote(newNote, parent, index);
 }