config.StoragePath

This commit is contained in:
William Gill
2025-10-05 22:10:48 +00:00
parent e5e1fff5e0
commit 1bd07883c2

View File

@@ -4,6 +4,7 @@ import (
"axis_timelapse/config"
"os"
"strconv"
"time"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
@@ -21,8 +22,9 @@ func CaptureImage() bool {
log.Error().Msg("Unexpected status code: " + strconv.Itoa(code))
}
// Write the bytes to a file
err1 := os.WriteFile("downloaded_image.jpg", body, 0644)
timestamp := time.Now()
filename := timestamp.Format("axis-2006-01-02_15-04-05.jpg")
err1 := os.WriteFile(config.StoragePath+filename, body, 0644)
if err1 != nil {
log.Fatal().Err(err1).Msgf("")
}