Serialize EXIF data for images

This commit is contained in:
Eli Ribble 2026-03-09 19:24:02 +00:00
parent 7c98a52133
commit 1be8c24235
No known key found for this signature in database

View file

@ -1,14 +1,39 @@
package types
import (
"encoding/json"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/google/uuid"
)
type Exif struct {
Created string `json:"created"`
Make string `json:"make"`
Model string `json:"model"`
}
type Image struct {
ExifMake string `db:"exif_make"`
ExifModel string `db:"exif_model"`
ExifDateTime string `db:"exif_datetime"`
Exif Exif `db:"-" json:"exif"`
ExifMake string `db:"exif_make" json:"-"`
ExifModel string `db:"exif_model" json:"-"`
ExifDateTime string `db:"exif_datetime" json:"-"`
Location Location `db:"location"`
NuisanceID int32 `db:"nuisance_id"`
URLContent string `db:"-" json:"url_content"`
UUID uuid.UUID `db:"uuid"`
}
func (i *Image) MarshalJSON() ([]byte, error) {
to_marshal := make(map[string]interface{}, 0)
to_marshal["exif"] = Exif{
Created: i.ExifDateTime,
Make: i.ExifMake,
Model: i.ExifModel,
}
to_marshal["location"] = i.Location
to_marshal["nuisance_id"] = i.NuisanceID
to_marshal["url_content"] = config.MakeURLNidus("/api/image/%s/content", i.UUID.String())
to_marshal["uuid"] = i.UUID
return json.Marshal(to_marshal)
}