Options
All
  • Public
  • Public/Protected
  • All
Menu

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 is input.ttl with content-type text/plain, the path would actually be input.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.

see

https://github.com/solid/community-server/issues/333

Hierarchy

  • ExtensionBasedMapper

Implements

Index

Constructors

constructor

  • new ExtensionBasedMapper(base: string, rootFilepath: string, overrideTypes?: { acl: string; meta: string }): ExtensionBasedMapper

Properties

Private Readonly baseRequestURI

baseRequestURI: string

Protected Readonly logger

logger: Logger = ...

Private Readonly rootFilepath

rootFilepath: string

Private Readonly types

types: Record<string, any>

Methods

Private getContentTypeFromExtension

  • getContentTypeFromExtension(path: string): string

Private getExtension

  • getExtension(path: string): null | string
  • Extracts the extension (without dot) from a path. Custom functin since path.extname does not work on all cases (e.g. ".acl")

    Parameters

    • path: string

      Input path to parse.

    Returns null | string

mapFilePathToUrl

  • mapFilePathToUrl(filePath: string, isContainer: boolean): Promise<ResourceLink>
  • Maps the given file path to an URL and determines the content-type

    Parameters

    • filePath: string

      The input file path.

    • isContainer: boolean

      If the path corresponds to a file.

    Returns Promise<ResourceLink>

    A ResourceLink with all the necessary metadata.

mapUrlToFilePath

  • 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.

    Parameters

    • identifier: ResourceIdentifier

      The input identifier.

    • Optional contentType: string

      The (optional) content-type of the resource.

    Returns Promise<ResourceLink>

    A ResourceLink with all the necessary metadata.