Refactor blog post logic to standardize field names and improve error handling; implement pagination for post listing and add tag retrieval functionality.
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
This commit is contained in:
@@ -31,8 +31,8 @@ func NewUploadPresignedURLLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
|
||||
func (l *UploadPresignedURLLogic) UploadPresignedURL(req *types.UploadPresignedURLReq) (resp *types.UploadPresignedURLResp, err error) {
|
||||
// Generate unique file key
|
||||
ext := filepath.Ext(req.File_name)
|
||||
fileKey := fmt.Sprintf("%s%s", uuid.New().String(), ext)
|
||||
ext := filepath.Ext(req.FileName)
|
||||
fileKey := fmt.Sprintf("uploads/%s%s", uuid.New().String(), ext)
|
||||
|
||||
// Calculate expiration time
|
||||
expiration := time.Duration(l.svcCtx.Config.S3.PresignedURLExpiration) * time.Second
|
||||
@@ -57,15 +57,15 @@ func (l *UploadPresignedURLLogic) UploadPresignedURL(req *types.UploadPresignedU
|
||||
|
||||
// Insert record into tmpfiles table
|
||||
query := `INSERT INTO tmpfiles (file_name, key, presigned_url, expiration) VALUES ($1, $2, $3, $4)`
|
||||
_, err = l.svcCtx.DB.ExecContext(l.ctx, query, req.File_name, fileKey, presignedReq.URL, expireAt)
|
||||
_, err = l.svcCtx.DB.ExecContext(l.ctx, query, req.FileName, fileKey, presignedReq.URL, expireAt)
|
||||
if err != nil {
|
||||
l.Errorf("Failed to insert tmpfile record: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UploadPresignedURLResp{
|
||||
Url: presignedReq.URL,
|
||||
File_key: fileKey,
|
||||
Expire_at: expireAt.Unix(),
|
||||
Url: presignedReq.URL,
|
||||
FileKey: fileKey,
|
||||
ExpireAt: expireAt.Unix(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user