mirror of
https://github.com/keven1024/015.git
synced 2026-06-01 01:49:37 +00:00
feat(worker): add file creation timestamp and file type in GenStandardFile function; implement new image processing functions
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
"worker/internal/models"
|
||||
"worker/internal/utils"
|
||||
)
|
||||
@@ -51,6 +52,8 @@ func GenStandardFile(filePath string, mimeType string) (GenStandardFileReturn, e
|
||||
FileHash: compressedFileHash,
|
||||
MimeType: mimeType,
|
||||
},
|
||||
FileType: models.FileTypeUpload,
|
||||
CreatedAt: time.Now().Unix(),
|
||||
})
|
||||
|
||||
return GenStandardFileReturn{
|
||||
|
||||
@@ -55,13 +55,18 @@ func CompressImage(ctx context.Context, task *asynq.Task) error {
|
||||
|
||||
models.SetRedisTaskInfo(task.ResultWriter().TaskID(), map[string]any{
|
||||
"status": "success",
|
||||
"old_file": map[string]any{
|
||||
"id": payload.FileId,
|
||||
"size": originalFileInfo.FileSize,
|
||||
},
|
||||
"new_file": map[string]any{
|
||||
"id": compressedFileInfo.FileId,
|
||||
"size": compressedFileInfo.FileSize,
|
||||
"result": []any{
|
||||
map[string]any{
|
||||
"status": "success",
|
||||
"old_file": map[string]any{
|
||||
"id": payload.FileId,
|
||||
"size": originalFileInfo.FileSize,
|
||||
},
|
||||
"new_file": map[string]any{
|
||||
"id": compressedFileInfo.FileId,
|
||||
"size": compressedFileInfo.FileSize,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user