Fix getMediaType logic #51

Merged
btzr-io merged 2 commits from patch-1 into master 2018-07-09 06:55:49 +02:00
btzr-io commented 2018-07-05 01:06:49 +02:00 (Migrated from github.com)

Changes

  • Improve media type detection of files with a contentType similar to application/something

Example

Most files don't follow a standar mime-type.
A simple .pdf file can contain a vendor-specific mime-type:

 PDF -> application/x-pdf, application/pdf, application/octet-stream

Usage

Before:

  const mediaType =
    (fileInfo && Lbry.getMediaType(null, fileInfo.file_name)) || Lbry.getMediaType(contentType);

After:

  const extname = path.extname(fileName) || mime.getExtension(contenType);
  const mediaType = Lbry.getMediaType(contentType, extname);

Required by:
https://github.com/lbryio/lbry-app/pull/1576
https://github.com/lbryio/lbry-app/pull/1558

### Changes - Improve media type detection of files with a `contentType` similar to `application/something` ### Example Most files don't follow a standar mime-type. A simple `.pdf` file can contain a vendor-specific mime-type: ``` PDF -> application/x-pdf, application/pdf, application/octet-stream ``` ### Usage Before: ```JS const mediaType = (fileInfo && Lbry.getMediaType(null, fileInfo.file_name)) || Lbry.getMediaType(contentType); ``` After: ```JS const extname = path.extname(fileName) || mime.getExtension(contenType); const mediaType = Lbry.getMediaType(contentType, extname); ``` Required by: https://github.com/lbryio/lbry-app/pull/1576 https://github.com/lbryio/lbry-app/pull/1558
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-redux#51
No description provided.