Files
axis_timelapse/camera/camera.go
William Gill eafa75614e getting there
2025-10-05 21:54:09 +00:00

32 lines
544 B
Go

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
}