Skip to content

Commit

Permalink
Add PDF to infer mime type list (#1298)
Browse files Browse the repository at this point in the history
Enables static PDF files to be returned. 

## What problem is it solving?

It will allow the download of static PDF files.

## How is the problem addressed?

By adding PDF to the infer mime type list. 

## Testing Instructions

- Check out this branch
- [Open Playground
](http://127.0.0.1:5400/website-server/?url=/wp-admin/upload.php)
- Upload a PDF as media
- Right click on Download file an open the link in a new tab
- See that the PDF loads

---------

Co-authored-by: Adam Zielinski <adam@adamziel.com>
  • Loading branch information
bgrgicak and adamziel authored Apr 23, 2024
1 parent b9352b2 commit f249af0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/php-wasm/universal/src/lib/php-request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,38 @@ function inferMimeType(path: string): string {
case 'txt':
case 'md':
return 'text/plain';
case 'pdf':
return 'application/pdf';
case 'webp':
return 'image/webp';
case 'mp3':
return 'audio/mpeg';
case 'mp4':
return 'video/mp4';
case 'csv':
return 'text/csv';
case 'xls':
return 'application/vnd.ms-excel';
case 'xlsx':
return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
case 'doc':
return 'application/msword';
case 'docx':
return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
case 'ppt':
return 'application/vnd.ms-powerpoint';
case 'pptx':
return 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
case 'zip':
return 'application/zip';
case 'rar':
return 'application/x-rar-compressed';
case 'tar':
return 'application/x-tar';
case 'gz':
return 'application/gzip';
case '7z':
return 'application/x-7z-compressed';
default:
return 'application-octet-stream';
}
Expand Down

0 comments on commit f249af0

Please sign in to comment.