Exemplo n.º 1
0
        public IActionResult Upload(IFormCollection form)
        {
            var stl        = form.Files[0];
            var subpath    = "/uploads/" + Guid.NewGuid().ToString() + ".stl";
            var filePath   = Startup._env.WebRootPath + subpath;
            var fileStream = FILE.Create(filePath);

            var stream = stl.OpenReadStream();

            stream.Seek(0, System.IO.SeekOrigin.Begin);
            stream.CopyTo(fileStream);
            stream.Close();
            fileStream.Close();

            var model = new UploadModel()
            {
                dt       = DateTime.Now,
                subpath  = subpath,
                filename = stl.FileName,
            };

            model.FillStlInfo(filePath);

            var id = db.Uploads.Insert(model);

            return(Json(new { id = id.AsString }));
        }
Exemplo n.º 2
0
        public void InsertFeaturedUpload(string name, string featured_stl, string featured_img, int adjust = 0, EAnimation anim = EAnimation.NONE)
        {
            var model = new UploadModel()
            {
                dt                = DateTime.Now,
                subpath           = "/stl_featured/" + featured_stl,
                thumbs            = new string[] { "/stl_featured/" + featured_img },
                filename          = Path.GetFileName(featured_stl),
                featured          = true,
                featured_name     = name,
                featured_adjust_y = adjust,
                featured_anim     = anim
            };

            model.FillStlInfo(Startup._env.WebRootPath + model.subpath);

            Uploads.Insert(model);
        }