public async Task <JsonResult> ViewOneFile(ViewOneFileAddressModel model) { var file = await _dbContext .OSSFile .Include(t => t.BelongingBucket) .SingleOrDefaultAsync(t => t.FileKey == model.FileKey); if (file == null || file.BelongingBucket == null) { return(this.Protocol(ErrorType.NotFound, "Could not find a valid file in OSS!")); } var path = _configuration["StoragePath"] + $@"{_}Storage{_}{file.BelongingBucket.BucketName}{_}{file.FileKey}.dat"; file.JFileSize = new FileInfo(path).Length; file.InternetPath = new AiurUrl(_serviceLocation.OSSEndpoint, file.BelongingBucket.BucketName, file.RealFileName, new { }).ToString(); var viewModel = new ViewOneFileViewModel { File = file, Code = ErrorType.Success, Message = "Successfully get that file!" }; return(Json(viewModel)); }
public async Task <JsonResult> ViewOneFile(ViewOneFileAddressModel model) { var file = await _dbContext .OSSFile .Include(t => t.BelongingBucket) .SingleOrDefaultAsync(t => t.FileKey == model.FileKey); var path = _configuration["StoragePath"] + $@"{_}Storage{_}{file.BelongingBucket.BucketName}{_}{file.FileKey}.dat"; file.JFileSize = new FileInfo(path).Length; var viewModel = new ViewOneFileViewModel { File = file, code = ErrorType.Success, message = "Successfully get that file!" }; return(Json(viewModel)); }