public virtual ActionResult BlogMLImport(FileUpload upload)
        {
            if (upload == null || string.IsNullOrWhiteSpace(upload.FileName))
            {
                ModelState.AddModelError("File", "Please select a file to upload.");
                return View();
            }

            var fullPath = Server.MapPath(SettingsProvider.GetSettings<FunnelWebSettings>().UploadPath);
            fullPath = Path.Combine(fullPath, upload.FileName);
            upload.SaveTo(fullPath);

            var id = ImportTask.Execute(new { inputFile = fullPath });
            return RedirectToAction("Task", new { id });
        }
        public void UploadAndUnzip()
        {
            var stream = new MemoryStream();

            var file = Substitute.For<HttpPostedFileBase>();
            file.InputStream.Returns(stream);

            var upload = new FileUpload(file);

            var result = (RedirectToRouteResult)Controller.Upload("path", true, upload);

            FileRepository.Received().Save(Arg.Is<Stream>(stream), Arg.Is("path"), Arg.Is(true));

            Assert.That(result.RouteValues["Action"], Is.EqualTo("Index"));
        }
示例#3
0
 public virtual ActionResult Upload(string path, bool? unzip, FileUpload upload)
 {
     var filePath = Path.Combine(path, upload.FileName);
     FileRepository.Save(upload.Stream, filePath, unzip ?? false);
     return RedirectToAction("Index", "Upload", new { path });
 }