diff --git a/pkg/internal/server/api/up_direct_api.go b/pkg/internal/server/api/up_direct_api.go index 698f065..8a5bb11 100644 --- a/pkg/internal/server/api/up_direct_api.go +++ b/pkg/internal/server/api/up_direct_api.go @@ -66,7 +66,12 @@ func createAttachmentDirectly(c *fiber.Ctx) error { tx.Commit() metadata.Pool = &pool - services.PublishAnalyzeTask(metadata) + + if !c.QueryBool("analyzeNow", false) { + services.AnalyzeAttachment(metadata) + } else { + services.PublishAnalyzeTask(metadata) + } return c.JSON(metadata) } diff --git a/pkg/internal/server/api/up_multipart_api.go b/pkg/internal/server/api/up_multipart_api.go index 32d2e95..f736b28 100644 --- a/pkg/internal/server/api/up_multipart_api.go +++ b/pkg/internal/server/api/up_multipart_api.go @@ -113,9 +113,14 @@ func uploadAttachmentMultipart(c *fiber.Ctx) error { return c.JSON(meta) } - if meta, err = services.MergeFileChunks(meta, chunkArrange); err != nil { + meta, err = services.MergeFileChunks(meta, chunkArrange) + if err != nil { return fiber.NewError(fiber.StatusInternalServerError, err.Error()) + } else if !c.QueryBool("analyzeNow", false) { + services.AnalyzeAttachment(meta) } else { - return c.JSON(meta) + services.PublishAnalyzeTask(meta) } + + return c.JSON(meta) }