Exemple #1
0
        public async Task <ApiResponse <PagedResult <UploadsListItem> > > GetUploads(UploadsGetListRequest request)
        {
            using (var scope = GlobalServices.Container.BeginLifetimeScope())
            {
                var repository = scope.Resolve <ICloudSpeedRepository>();
                var paramMap   = await request.ToParamMapDTO();

                var total = await repository.CountUploadLogs(paramMap);

                var entities = await repository.GetUploadLogs(paramMap, request.Skip, request.Limit);

                var uploadLogs = entities.ToList();
                var result     = new List <UploadsListItem>();
                foreach (var uploadLog in uploadLogs)
                {
                    var item = new UploadsListItem
                    {
                        Id      = uploadLog.Id,
                        Created = uploadLog.Created,
                    };
                    var fileCid = await repository.GetFileCid(uploadLog.DataKey);

                    var fileName = await repository.GetFileName(fileCid.Id);

                    var path   = _uploadSetting.GetStoragePath(fileCid.Id);
                    var member = await _memberManager.FindByIdAsync(uploadLog.UserId);

                    var mimeType = fileName.GetMimeType();
                    item.Cid      = fileCid.Cid;
                    item.UserName = member?.UserName;
                    item.FileName = fileName;
                    item.Format   = mimeType;
                    item.FileSize = new FileInfo(path).ToFileSize();
                    result.Add(item);
                }
                return(ApiResponse.Ok(request.ToPagedResult(result, total)));
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetList([FromBody] UploadsGetListRequest request)
        {
            var data = await _UploadsManager.GetUploads(request);

            return(Result(data));
        }