static Task <Upload> CreateUpload(this IFormFile file, string path, string url) => Task.Run(() =>
        {
            var name = file.CreateSafeName(path);

            var upload = new Upload
            {
                File = name,
                Name = file.Name,
                Path = $"{path}{name}",
                Url  = $"{url}{name}"
            };

            return(upload);
        });
Example #2
0
 // Translate IFormFile into UploadModel
 private static Task <UploadModel> CreateUploadModel(this IFormFile file, string uploadUrl)
 {
     return(Task.Run(() =>
     {
         var name = file.CreateSafeName(uploadUrl);
         var model = new UploadModel
         {
             Name = name,
             File = file.Name,
             Path = $"{uploadUrl}{name}",
             Url = ($"{uploadUrl}{name}").CheckUrlPath()
         };
         return model;
     }));
 }
Example #3
0
        static Task <Upload> CreateUpload(this IFormFile file, string path, string url) => Task.Run(() =>
        {
            var f = file.CreateSafeName(path);

            var upload = new Upload
            {
                File     = f,
                Name     = file.Name,
                Path     = $"{path}{f}",
                Url      = $"{url}{f}",
                FileType = file.ContentType,
                Size     = file.Length
            };

            return(upload);
        });
        static Task <Upload> CreateUpload(this IFormFile file, string path, string url, int userId) => Task.Run(() =>
        {
            var f = file.CreateSafeName(path);

            var upload = new Upload
            {
                UserId   = userId,
                File     = f,
                Name     = file.Name,
                Path     = $"{path}{f}",
                Url      = $"{url}{f}",
                FileType = file.ContentType,
                Size     = file.Length,
                // UploadDate = DateTime.Now,
                // IsDeleted = false
            };

            return(upload);
        });