getting there

This commit is contained in:
William Gill
2025-10-05 21:54:09 +00:00
parent 6fdb5ead36
commit eafa75614e
891 changed files with 644353 additions and 45 deletions

31
camera/camera.go Normal file
View File

@@ -0,0 +1,31 @@
package camera
import (
"axis_timelapse/config"
"os"
"strconv"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
)
func CaptureImage() bool {
request := fiber.Get(config.FullURL)
code, body, err := request.Bytes()
if err != nil {
log.Error().Msgf("Error getting image.")
}
if code != 200 {
log.Error().Msg("Unexpected status code: " + strconv.Itoa(code))
}
// Write the bytes to a file
err1 := os.WriteFile("downloaded_image.jpg", body, 0644)
if err1 != nil {
log.Fatal().Err(err1).Msgf("")
}
return true
}