ep_media_upload 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +22 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -484,14 +484,33 @@ exports.expressCreateServer = (hookName, context) => {
484
484
  ? `inline; filename="${filename}"`
485
485
  : `attachment; filename="${filename}"`;
486
486
 
487
+ // Map extensions to canonical MIME types for consistent browser playback
488
+ const EXTENSION_CONTENT_TYPE = {
489
+ mp3: 'audio/mpeg',
490
+ wav: 'audio/wav',
491
+ mp4: 'video/mp4',
492
+ mov: 'video/quicktime',
493
+ webm: 'video/webm',
494
+ ogg: 'audio/ogg',
495
+ m4a: 'audio/mp4',
496
+ pdf: 'application/pdf',
497
+ };
498
+
487
499
  // Generate presigned GET URL with short expiry
488
- // Use ResponseContentDisposition to override the stored header
500
+ // Use ResponseContentDisposition and ResponseContentType to override stored headers
489
501
  const s3Client = new S3Client({ region });
490
- const getCommand = new GetObjectCommand({
502
+ const commandParams = {
491
503
  Bucket: bucket,
492
504
  Key: key,
493
505
  ResponseContentDisposition: disposition,
494
- });
506
+ };
507
+
508
+ // Set canonical Content-Type for inline extensions to ensure browser compatibility
509
+ if (shouldOpenInline && fileExtension && EXTENSION_CONTENT_TYPE[fileExtension.toLowerCase()]) {
510
+ commandParams.ResponseContentType = EXTENSION_CONTENT_TYPE[fileExtension.toLowerCase()];
511
+ }
512
+
513
+ const getCommand = new GetObjectCommand(commandParams);
495
514
 
496
515
  // Use downloadExpires from config, default to 300 seconds (5 minutes)
497
516
  const expiresIn = downloadExpires || 300;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ep_media_upload",
3
3
  "description": "beta - Upload files to S3 and insert hyperlinks into the pad. Requires ep_hyperlinked_text.",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "author": {
6
6
  "name": "DCastelone",
7
7
  "url": "https://github.com/dcastelone"