package wde import ( "errors" "personalwebsite/webfilesystem" "go.mongodb.org/mongo-driver/bson/primitive" ) func ReadImage(img *webfilesystem.WebFSFile) (*Base64Img, error) { header, ok := img.Data.(primitive.D).Map()["header"].(string) if !ok { return nil, errors.New("error in file decoding") } base64, ok := img.Data.(primitive.D).Map()["base64"].(string) if !ok { return nil, errors.New("error in file decoding") } return &Base64Img{ Header: header, Base64: base64, }, nil } type Base64Img struct { Header string Base64 string }