-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileApiController.cs
54 lines (40 loc) · 1.9 KB
/
FileApiController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
[HttpPost("aws")]
public async Task<ActionResult<ItemResponse<object>>> UploadAWS(List<IFormFile> files)
{
BaseResponse response = null;
FileAddRequest _file = null;
List<FileUpload> list = new List<FileUpload>();
int id = 0;
int iCode = 200;
try
{
int userId = _authService.GetCurrentUserId();
IUserAuthData name = _authService.GetCurrentUser();
List<FileUpload> urls = await _service.AddAws(files);
_file = new FileAddRequest();
foreach (var item in urls)
{
_file.Url = item.Url;
_file.FileTypeId = 1;
_file.FirstName = name.Name;
_file.LastName = name.Name;
_file.Name = item.Name;
id = _service.Add(_file, userId);
list.Add(new FileUpload { Id = id,
Url = _file.Url,
Name = _file.Name,
LastName = _file.LastName,
FirstName = _file.FirstName,
FileTypeId = _file.FileTypeId,
CreatedBy = userId,
DateCreated = DateTime.UtcNow });
}
response = new ItemResponse<List<FileUpload>> { Item = list };
}
catch(Exception ex)
{
base.Logger.LogError(ex.ToString());
response = new ErrorResponse($"Generic Errors: ${ex.Message}");
}
return StatusCode(iCode, response);
}