Пример #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.ProcessWebInputfile(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());
            }
        }
Пример #2
0
 public IActionResult Post([FromBody] DumpAnalysisInput input)
 {
     if (ModelState.IsValid)
     {
         string bundleId = superDumpRepo.ProcessWebInputfile(input);
         //validate URL
         if (!string.IsNullOrEmpty(bundleId))
         {
             logger.LogFileUpload("Api Upload", HttpContext, bundleId, input.CustomProperties, input.Url);
             return(CreatedAtAction(nameof(HomeController.BundleCreated), "Home", new { bundleId = bundleId }, null));
         }
         else
         {
             logger.LogNotFound("Api Upload: File not found", HttpContext, "Url", input.Url);
             return(BadRequest("Invalid request, resource identifier is not valid or cannot be reached."));
         }
     }
     else
     {
         var errors = string.Join("; ", ModelState.Values.SelectMany(v => v.Errors).Select(x => "'" + x.Exception.Message + "'"));
         return(BadRequest($"Invalid request, check if value was set: {errors}"));
     }
 }
Пример #3
0
 public IActionResult Post([FromBody] DumpAnalysisInput input)
 {
     if (ModelState.IsValid)
     {
         string filename = input.UrlFilename;
         //validate URL
         if (Utility.ValidateUrl(input.Url, ref filename))
         {
             if (filename == null && Utility.IsLocalFile(input.Url))
             {
                 filename = Path.GetFileName(input.Url);
             }
             string bundleId = superDumpRepo.ProcessWebInputfile(filename, input);
             if (bundleId != null)
             {
                 logger.LogFileUpload("Api Upload", HttpContext, bundleId, input.CustomProperties, input.Url);
                 return(CreatedAtAction(nameof(HomeController.BundleCreated), "Home", new { bundleId = bundleId }, null));
             }
             else
             {
                 // in case the input was just symbol files, we don't get a bundleid.
                 // TODO
                 throw new NotImplementedException();
             }
         }
         else
         {
             logger.LogNotFound("Api Upload: File not found", HttpContext, "Url", input.Url);
             return(BadRequest("Invalid request, resource identifier is not valid or cannot be reached."));
         }
     }
     else
     {
         var errors = string.Join("; ", ModelState.Values.SelectMany(v => v.Errors).Select(x => "'" + x.Exception.Message + "'"));
         return(BadRequest($"Invalid request, check if value was set: {errors}"));
     }
 }