-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 57 Integrate gql upload mutation * Fix createdAt field * Add non null to singleUpload mutation * add endpoints to get single file and recent files * Add fileBlob cleanup with Hangfire * Fix daily blob delete schedule * missing rest controller init; FileBlob seed data * Fix PR comment about configurable max_file_size * Fix PR comments: fix test, refactor recurringJobs * Update DeleteOldFileBlobsJob.cs --------- Co-authored-by: Ion Dormenco <[email protected]>
- Loading branch information
Showing
36 changed files
with
763 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,3 +336,10 @@ ASALocalRun/ | |
# Project specific | ||
postgres_data | ||
.env | ||
|
||
# VSCode | ||
.vscode | ||
|
||
# MacOS | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using TeacherWorkout.Data; | ||
|
||
namespace TeacherWorkout.Api.Controllers | ||
{ | ||
[Route("file")] | ||
[ApiController] | ||
public class FileController(TeacherWorkoutContext context) : ControllerBase | ||
{ | ||
private readonly TeacherWorkoutContext _context = context; | ||
|
||
[HttpGet("{id}")] | ||
public async Task<IActionResult> GetImage(string id) | ||
{ | ||
var fileBlob = await _context.FileBlobs.FindAsync(id); | ||
if (fileBlob == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return File(fileBlob.Content, fileBlob.Mimetype); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using GraphQL.Types; | ||
using TeacherWorkout.Domain.Models; | ||
|
||
namespace TeacherWorkout.Api.GraphQL.Types | ||
{ | ||
public class FileBlobType : ObjectGraphType<FileBlob> | ||
{ | ||
public FileBlobType() | ||
{ | ||
Name = "FileBlob"; | ||
|
||
Field(x => x.Id, nullable: false).Description("The unique identifier of the file blob."); | ||
Field(x => x.CreatedAt, nullable: false).Description("The creation time of the file blob."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
TeacherWorkout.Api/GraphQL/Types/Payloads/SingleUploadPayloadType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using GraphQL.Types; | ||
using TeacherWorkout.Domain.Models.Payloads; | ||
|
||
namespace TeacherWorkout.Api.GraphQL.Types.Payloads | ||
{ | ||
public class SingleUploadPayloadType : ObjectGraphType<SingleUploadPayload> | ||
{ | ||
public SingleUploadPayloadType() | ||
{ | ||
Name = "SingleUploadPayload"; | ||
|
||
Field(x => x.FileBlobId).Description("The ID of the created file blob."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace TeacherWorkout.Api.Jobs.Config | ||
{ | ||
public record DeleteOldFileBlobsConfig : RecurringJobConfig | ||
{ | ||
public int DaysInThePast { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace TeacherWorkout.Api.Jobs.Config | ||
{ | ||
public record RecurringJobConfig | ||
{ | ||
public bool IsEnabled { get; set; } | ||
public string CronExpression { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Extensions.Options; | ||
using TeacherWorkout.Api.Jobs.Interfaces; | ||
using TeacherWorkout.Domain.FileBlobs; | ||
using TeacherWorkout.Api.Jobs.Config; | ||
|
||
namespace TeacherWorkout.Api.Jobs | ||
{ | ||
|
||
public class DeleteOldFileBlobsJob(IFileBlobRepository repository, IOptions<DeleteOldFileBlobsConfig> config) : IDeleteOldFileBlobsJob | ||
{ | ||
private readonly IFileBlobRepository _repository = repository; | ||
private readonly DeleteOldFileBlobsConfig _config = config.Value; | ||
|
||
public void Run() | ||
{ | ||
; | ||
_repository.DeleteOldEntries(_config.DaysInThePast); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
TeacherWorkout.Api/Jobs/Interfaces/IDeleteOldFileBlobsJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace TeacherWorkout.Api.Jobs.Interfaces | ||
{ | ||
public interface IDeleteOldFileBlobsJob | ||
{ | ||
void Run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.