feat: update ppid files services

This commit is contained in:
hanif salafi 2024-07-20 15:33:04 +07:00
parent dca71f253a
commit 3a1335720d
1 changed files with 25 additions and 5 deletions

View File

@ -16,7 +16,6 @@ import (
"log"
"math/rand"
"mime"
"path"
"path/filepath"
"strconv"
"strings"
@ -105,6 +104,22 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
}
files := form.File["files"]
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service", "Save").
Interface("titlesString", titlesString).Msg("")
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service", "Save").
Interface("typesString", typesString).Msg("")
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service", "Save").
Interface("positionsString", positionsString).Msg("")
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service", "Save").
Interface("urlsString", urlsString).Msg("")
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service", "Save").
Interface("urls", urls).Msg("")
fileCounter := 0
urlCounter := 0
@ -113,6 +128,11 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
Interface("form", files).Msg("")
for index, fileType := range types {
_i.Log.Info().Str("timestamp", time.Now().
Format(time.RFC3339)).Str("Service", "Save").
Interface("types", fileType).Msg("")
position := &positions[index]
positionInt64, err := strconv.ParseInt(*position, 10, 0)
if err != nil {
@ -135,14 +155,14 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
if fileType == "url" {
url := urls[urlCounter]
filename := path.Base(url)
//filename := path.Base(url)
//filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))])
extension := filepath.Ext(filename)[1:]
//extension := filepath.Ext(filename)[1:]
//title := strings.ReplaceAll(filenameWithoutExt, "-", " ")
//req.Title = &title
req.FileType = &extension
req.FileName = &filename
//req.FileType = &extension
req.FileName = &title
req.FileUrl = &url
urlCounter += 1