The code below results in the error:
Error: undeclared field: 'mimes' for type mimetypes.MimeDB [declared in ...]
found 'mimes' of kind 'const'
I do not understand why and see no way out.
import mimetypes
from strutils import toLowerAscii
var mime = newMimetypes()
mime.register("ape", "audio/x-ape")
func getExtensions(mimedb: MimeDB, mimetype: string, default = "undefined"): seq[string] =
let mimeLowered = mimetype.toLowerAscii()
for e, m in mimedb.mimes: #<--- errors here
if mimelowerer.find("audio") > -1:
echo e
result.add(e)
#Error: undeclared field: 'mimes' for type mimetypes.MimeDB [declared in ...]
# found 'mimes' of kind 'const'
TIA
The MimeDB ref object is declared as follows in mimetypes.nim:
type
MimeDB* = object
mimes: StringTableRef
The 'mimes' in the object doesn't have an export marker (an asterisk) so it's not visible to your code. There's a separate 'mimes' constant just below it in the same file that is exported so that could probably be used instead, although that wouldn't help you if you register your own types.