Get the content type from a file path, using its extension.
The file path.
Content type of the file.
Extracts the extension (without dot) from a path.
Custom functin since path.extname
does not work on all cases (e.g. ".acl")
Input path to parse.
Maps the given file path to an URL and determines the content-type
The input file path.
If the path corresponds to a file.
A ResourceLink with all the necessary metadata.
Maps the given resource identifier / URL to a file path. Determines the content-type if no content-type was provided. For containers the content-type input gets ignored.
The input identifier.
The (optional) content-type of the resource.
A ResourceLink with all the necessary metadata.
A mapper that stores the content-type of resources in the file path extension. In case the extension of the identifier does not correspond to the correct content-type, a new extension will be appended (with a
$
in front of it). E.g. if the path isinput.ttl
with content-typetext/plain
, the path would actually beinput.ttl$.txt
. This new extension is stripped again when generating an identifier.Warning: Since this mapper iterates over all files in the requested directory, it can experience performance issues over directories with a huge number of files (10.000+). For typical directory structures, the performance of this mapper should be sufficient.
https://github.com/solid/community-server/issues/333