chrly/db/capes/files/repository.go

27 lines
448 B
Go

package files
import (
"os"
"path"
"strings"
"elyby/minecraft-skinsystem/model"
)
type filesDb struct {
path string
}
func (repository *filesDb) FindByUsername(username string) (model.Cape, error) {
var record model.Cape
capePath := path.Join(repository.path, strings.ToLower(username) + ".png")
file, err := os.Open(capePath)
if err != nil {
return record, CapeNotFoundError{username}
}
record.File = file
return record, nil
}