Unable to represent a file data type

63 views
Skip to first unread message

Qali Fah

unread,
Sep 8, 2020, 1:44:33 PM9/8/20
to golang-nuts
Hello everyone, i'm trying to create a music store API, where you can basically listen and buy songs. The problems i'm having are how i would represent the artwork(picture file) and song (music file) in gorm (Golang ORM library) and in what format do i return it to the client after being stored and are there external packages i can use to simplify things? Thank you. 

Ronny Bangsund

unread,
Sep 8, 2020, 5:17:11 PM9/8/20
to golang-nuts


On Tuesday, September 8, 2020 at 7:44:33 PM UTC+2, Qali Fah wrote:
The problems i'm having are how i would represent the artwork(picture file) and song (music file) in gorm (Golang ORM library) and in what format do i return it to the client after being stored and are there external packages i can use to simplify things?
I'd use filenames locally and return URLs to media. Reference the music and image files rather than stuffing them into the database. Store names, filenames and all the metadata you think makes sense (artist, album, genre and all sorts of extra tags) in the music file table.

If presenting a web API, JSON is perfectly fine (and most common). Any web frontends are likely to be JS anyway, so use a natively easy to use format. The built-in packages in the Go distribution can get you all the way, but if you like a little extra help with routing, Chi is a decent option:


Reply all
Reply to author
Forward
0 new messages