26 lines
604 B
Go
26 lines
604 B
Go
package translators
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
|
|
)
|
|
|
|
type Media struct {
|
|
Type string `json:"type"`
|
|
Url string `json:"url"`
|
|
MediaType string `json:"mediaType"`
|
|
}
|
|
|
|
func MediaFromStorage(ctx context.Context, id string) (*Media, error) {
|
|
metadata, err := dbgen.MediaMetadata.Where(dbgen.MediaMetadata.ID.Eq(id)).First()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
data := Media{
|
|
Type: "Image", // FIXME: Change this to a sort of dynamic detection based on mimetype
|
|
MediaType: metadata.Type,
|
|
Url: metadata.Location,
|
|
}
|
|
return &data, nil
|
|
}
|