@hdriel/aws-utils 1.3.3 → 1.3.4

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.
package/dist/index.cjs CHANGED
@@ -286,6 +286,7 @@ var import_client_s37 = require("@aws-sdk/client-s3");
286
286
 
287
287
  // src/aws/s3/s3-stream.ts
288
288
  var import_pathe2 = require("pathe");
289
+ var import_mime_types = __toESM(require("mime-types"), 1);
289
290
  var import_stream = require("stream");
290
291
  var import_util = require("util");
291
292
  var import_buffer2 = require("buffer");
@@ -1676,10 +1677,10 @@ var S3Stream = class _S3Stream extends S3File {
1676
1677
  if (fileInfo.ContentLength) {
1677
1678
  res.setHeader("Content-Length", String(fileInfo.ContentLength));
1678
1679
  }
1679
- if (forDownloading || !canDisplayInline) {
1680
- res.setHeader("Content-Disposition", `attachment; filename="${encodeURIComponent(fileName)}"`);
1681
- } else {
1680
+ if (forDownloading === false || forDownloading === void 0 && canDisplayInline) {
1682
1681
  res.setHeader("Content-Disposition", `inline; filename="${encodeURIComponent(fileName)}"`);
1682
+ } else {
1683
+ res.setHeader("Content-Disposition", `attachment; filename="${encodeURIComponent(fileName)}"`);
1683
1684
  }
1684
1685
  const cachingAge = !_cachingAge || typeof _cachingAge === "number" ? _cachingAge : getTotalSeconds(_cachingAge);
1685
1686
  if (cachingAge) {
@@ -1907,7 +1908,10 @@ var S3Stream = class _S3Stream extends S3File {
1907
1908
  acl,
1908
1909
  s3: this.s3Client,
1909
1910
  bucket: this.bucket,
1910
- contentType: import_multer_s3.default.AUTO_CONTENT_TYPE,
1911
+ contentType: function(_req, file, cb) {
1912
+ const contentType = file.mimetype || import_mime_types.default.lookup(file.originalname) || "application/octet-stream";
1913
+ cb(null, contentType);
1914
+ },
1911
1915
  metadata: (req, file, cb) => __async(this, null, function* () {
1912
1916
  const originalName = decodeURIComponent(file.originalname);
1913
1917
  const baseMetadata = __spreadProps(__spreadValues({}, file), {
package/dist/index.js CHANGED
@@ -246,6 +246,7 @@ import { ListObjectsV2Command as ListObjectsV2Command4 } from "@aws-sdk/client-s
246
246
 
247
247
  // src/aws/s3/s3-stream.ts
248
248
  import { basename as basename2, extname } from "pathe";
249
+ import mime from "mime-types";
249
250
  import { pipeline } from "stream";
250
251
  import { promisify } from "util";
251
252
  import { Buffer as Buffer3 } from "buffer";
@@ -1664,10 +1665,10 @@ var S3Stream = class _S3Stream extends S3File {
1664
1665
  if (fileInfo.ContentLength) {
1665
1666
  res.setHeader("Content-Length", String(fileInfo.ContentLength));
1666
1667
  }
1667
- if (forDownloading || !canDisplayInline) {
1668
- res.setHeader("Content-Disposition", `attachment; filename="${encodeURIComponent(fileName)}"`);
1669
- } else {
1668
+ if (forDownloading === false || forDownloading === void 0 && canDisplayInline) {
1670
1669
  res.setHeader("Content-Disposition", `inline; filename="${encodeURIComponent(fileName)}"`);
1670
+ } else {
1671
+ res.setHeader("Content-Disposition", `attachment; filename="${encodeURIComponent(fileName)}"`);
1671
1672
  }
1672
1673
  const cachingAge = !_cachingAge || typeof _cachingAge === "number" ? _cachingAge : getTotalSeconds(_cachingAge);
1673
1674
  if (cachingAge) {
@@ -1895,7 +1896,10 @@ var S3Stream = class _S3Stream extends S3File {
1895
1896
  acl,
1896
1897
  s3: this.s3Client,
1897
1898
  bucket: this.bucket,
1898
- contentType: multerS3.AUTO_CONTENT_TYPE,
1899
+ contentType: function(_req, file, cb) {
1900
+ const contentType = file.mimetype || mime.lookup(file.originalname) || "application/octet-stream";
1901
+ cb(null, contentType);
1902
+ },
1899
1903
  metadata: (req, file, cb) => __async(this, null, function* () {
1900
1904
  const originalName = decodeURIComponent(file.originalname);
1901
1905
  const baseMetadata = __spreadProps(__spreadValues({}, file), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hdriel/aws-utils",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Simplified AWS SDK (v3) utilities for S3 (upload, download, streaming) with TypeScript support",
5
5
  "author": "Hadriel Benjo (https://github.com/hdriel)",
6
6
  "type": "module",
@@ -49,6 +49,7 @@
49
49
  "aws-crt": "1.27.3",
50
50
  "aws-lambda": "1.0.7",
51
51
  "bytes": "3.1.2",
52
+ "mime-types": "^3.0.1",
52
53
  "ms": "2.1.3",
53
54
  "multer": "2.0.2",
54
55
  "multer-s3": "3.0.1",
@@ -62,6 +63,7 @@
62
63
  "@types/aws-lambda": "8.10.153",
63
64
  "@types/bytes": "3.1.5",
64
65
  "@types/express": "5.0.3",
66
+ "@types/mime-types": "^3.0.1",
65
67
  "@types/ms": "2.1.0",
66
68
  "@types/multer": "2.0.0",
67
69
  "@types/multer-s3": "3.0.3",
@@ -69,8 +71,8 @@
69
71
  "express": "^5.1.0",
70
72
  "prettier": "^3.6.2",
71
73
  "ts-node": "^10.9.2",
72
- "tsup": "^8.5.0",
73
74
  "tslint": "^6.1.3",
75
+ "tsup": "^8.5.0",
74
76
  "typescript": "^5.9.2"
75
77
  }
76
78
  }