Esempio n. 1
0
        public IActionResult CreateBlobItem([FromForm] ICreateBlob postData)
        {
            BlobItem b = handler.CreateBlobItem(postData);

            if (b == null)
            {
                return(Conflict("Error! Maybe you did not gave us all the needed info?"));
            }

            return(Created("", b));
        }
 public static BlobItem Create(ICreateBlob postInfo, int id, string uploadPath)
 {
     return(new BlobItem
     {
         FileId = id,
         FileName = postInfo.file.FileName,
         Date = Convert.ToDateTime(DateTime.Today.ToString("dd-MM-yyyy")),
         Path = uploadPath,
         FileSize = (int)postInfo.file.Length / 1024,
         UserId = postInfo.userId,
         Description = postInfo.description
     });
 }
        public BlobItem CreateFolderBlobItem(ICreateBlob postData, int folderId)
        {
            BlobItem b = this.blobModel.CreateBlobItem(postData);

            if (b == null)
            {
                return(null);
            }

            FolderItem f = FolderBlobFactory.Create(b.FileId, folderId);

            _context.FolderItems.Add(f);
            _context.SaveChanges();
            return(b);
        }
        public IActionResult CreateFolderBlobItem([FromForm] ICreateBlob postData, [FromForm] int folderId)
        {
            if (!this.handler.DoesFolderExist(folderId))
            {
                return(NotFound());
            }

            SetFolderEnvironment();

            BlobItem b = this.handler.CreateFolderBlobItem(postData, folderId);

            if (b == null)
            {
                return(Conflict("Error! Maybe you did not gave us all the needed info?"));
            }

            return(Created("", b));
        }
        public BlobItem CreateBlobItem(ICreateBlob postData)
        {
            int      id       = this.GenerateId();
            BlobItem blobItem = BlobItemFactory.Create(postData, id, Storage.CreatePathFile(postData.file.FileName));

            if (blobItem == null)
            {
                return(null);
            }

            string fileName = Path.GetFileName(blobItem.Path);

            if (!Storage.Create(fileName, postData.file).Result)
            {
                return(null);
            }

            _context.BlobItem.Add(blobItem); //set file in the "db"
            _context.SaveChanges();

            return(blobItem);
        }
 public BlobItem CreateBlobItem(ICreateBlob postData)
 {
     return(model.CreateBlobItem(postData));
 }
 public BlobItem CreateFolderBlobItem(ICreateBlob postData, int folderId)
 {
     return(this.Model.CreateFolderBlobItem(postData, folderId));
 }