Esempio n. 1
0
        public ActionResult <bool> Add(int ownerId)
        {
            FileRepository repository = new FileRepository(context);
            var            file       = Request.Form.Files.FirstOrDefault();

            //write to file system
            string path = fileService.WriteToFileSystem(ownerId, file);

            // add file to the database
            string size      = ((int)(file.Length / 1024f)).ToString() + "kb";
            string name      = Path.GetFileNameWithoutExtension(path);
            string extension = Path.GetExtension(path);
            var    response  = repository.AddFile(ownerId, size, name, file.ContentType, path, extension);

            return(response);
        }