admin: Export logos present in challenge.json
This commit is contained in:
parent
590a55c395
commit
3fc765ccfa
2 changed files with 56 additions and 0 deletions
|
|
@ -238,3 +238,21 @@ func WriteFileContent(i Importer, URI string, content []byte) error {
|
|||
return fmt.Errorf("%t is not capable of writing", i)
|
||||
}
|
||||
}
|
||||
|
||||
func OpenOrGetFile(i Importer, URI string) (fd io.Reader, closer func() error, err error) {
|
||||
if strings.HasPrefix(URI, "$FILES$") {
|
||||
var fdc io.ReadCloser
|
||||
fdc, err = os.Open(path.Join(fic.FilesDir, strings.TrimPrefix(URI, "$FILES$/")))
|
||||
fd = fdc
|
||||
closer = fdc.Close
|
||||
} else {
|
||||
fd, err = GlobalImporter.GetFile(URI)
|
||||
if fdcloser, ok := fd.(io.ReadCloser); ok {
|
||||
closer = fdcloser.Close
|
||||
} else {
|
||||
closer = func() error { return nil }
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue