public FileViewModel Build(File file)
 {
     return new FileViewModel()
       {
     Id = file.Id,
     Name = file.Name,
     Size = file.Size
       };
 }
Exemplo n.º 2
0
    public async Task<IActionResult> Create(IList<IFormFile> files)
    {
      foreach (IFormFile source in files)
      {
        string filename = ContentDispositionHeaderValue.Parse(source.ContentDisposition).FileName.Trim('"');

        filename = this.EnsureCorrectFilename(filename);
        await source.SaveAsAsync(this.GetPathAndFilename(filename));

        File file = new File();

        file.Name = filename;
        file.Size = source.Length;
        this.Storage.GetRepository<IFileRepository>().Create(file);
        this.Storage.Save();
      }
      
      return this.RedirectToAction("Index");
    }