Exemplo n.º 1
0
        public IActionResult Create(DumpAnalysisInput input)
        {
            pathHelper.PrepareDirectories();

            if (ModelState.IsValid)
            {
                System.Diagnostics.Debug.WriteLine(input.Url);

                string filename = input.UrlFilename;
                if (Utility.ValidateUrl(input.Url, ref filename))
                {
                    if (filename == null && Utility.IsLocalFile(input.Url))
                    {
                        filename = Path.GetFileName(input.Url);
                    }
                    string bundleId = superDumpRepo.ProcessInputfile(filename, input);
                    logger.LogFileUpload("Upload", HttpContext, bundleId, input.CustomProperties, input.Url);
                    // return list of file paths from zip
                    return(RedirectToAction("BundleCreated", "Home", new { bundleId = bundleId }));
                }
                else
                {
                    logger.LogNotFound("Upload", HttpContext, "Url", input.Url);
                    return(BadRequest("Provided URI is invalid or cannot be reached."));
                }
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Upload(IFormFile file, string refurl, string note)
 {
     if (ModelState.IsValid)
     {
         pathHelper.PrepareDirectories();
         if (file.Length > 0)
         {
             var tempDir = new DirectoryInfo(pathHelper.GetTempDir());
             tempDir.Create();
             var filePath = new FileInfo(Path.Combine(tempDir.FullName, file.FileName));
             using (var fileStream = new FileStream(filePath.FullName, FileMode.Create)) {
                 await file.CopyToAsync(fileStream);
             }
             var bundle = new DumpAnalysisInput(filePath.FullName, new Tuple <string, string>("ref", refurl), new Tuple <string, string>("note", note));
             return(Create(bundle));
         }
         return(View("UploadError", new Error("No filename was provided.", "")));
     }
     else
     {
         return(View("UploadError", new Error("Invalid model", "Invalid model")));
     }
 }