@hdriel/aws-utils 1.2.3 → 1.2.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
@@ -1421,7 +1421,7 @@ var S3Stream = class _S3Stream extends S3File {
1421
1421
  this.maxUploadFileSizeRestriction = maxUploadFileSizeRestriction;
1422
1422
  this.s3Limiter = concurrencyVideoLimit ? (0, import_p_limit.default)(concurrencyVideoLimit) : null;
1423
1423
  }
1424
- streamObjectFile(_0) {
1424
+ getObjectFileStream(_0) {
1425
1425
  return __async(this, arguments, function* (fileKey, {
1426
1426
  Range,
1427
1427
  checkFileExists = true,
@@ -1641,7 +1641,7 @@ var S3Stream = class _S3Stream extends S3File {
1641
1641
  next(Error(`File not found: "${normalizedKey}"`));
1642
1642
  return;
1643
1643
  }
1644
- stream = yield this.streamObjectFile(normalizedKey, {
1644
+ stream = yield this.getObjectFileStream(normalizedKey, {
1645
1645
  abortSignal: abort.signal,
1646
1646
  checkFileExists: false
1647
1647
  });
@@ -1651,9 +1651,9 @@ var S3Stream = class _S3Stream extends S3File {
1651
1651
  return;
1652
1652
  }
1653
1653
  const fileInfo = yield this.fileInfo(normalizedKey);
1654
- const fileName = filename || normalizedKey.split("/").pop() || "download";
1655
1654
  const contentType = fileInfo.ContentType || "application/octet-stream";
1656
1655
  const ext = (0, import_pathe2.extname)(fileKey).slice(1).toLowerCase();
1656
+ const fileName = filename || normalizedKey.split("/").pop() || `${Date.now()}.${ext}`;
1657
1657
  const inlineTypes = ["text/", "image/", "application/pdf", "video/", "audio/"];
1658
1658
  const canDisplayInline = SUPPORTED_IFRAME_EXTENSIONS.includes(ext) || inlineTypes.some((type) => contentType.startsWith(type));
1659
1659
  res.setHeader("Content-Type", contentType);
@@ -1669,6 +1669,7 @@ var S3Stream = class _S3Stream extends S3File {
1669
1669
  if (cachingAge) {
1670
1670
  res.setHeader("Cache-Control", `public, max-age=${cachingAge}`);
1671
1671
  }
1672
+ res.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Disposition, Content-Length");
1672
1673
  stream.on("error", (err) => {
1673
1674
  var _a3, _b2;
1674
1675
  (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "Stream error", { fileKey: normalizedKey, error: err });
@@ -1743,7 +1744,7 @@ var S3Stream = class _S3Stream extends S3File {
1743
1744
  var _a3, _b2, _c2;
1744
1745
  try {
1745
1746
  if (abort.signal.aborted) return null;
1746
- const stream = yield this.streamObjectFile(fileKey2, { abortSignal: abort.signal });
1747
+ const stream = yield this.getObjectFileStream(fileKey2, { abortSignal: abort.signal });
1747
1748
  if (!stream) {
1748
1749
  (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "File not found", { fileKey: fileKey2 });
1749
1750
  return null;
package/dist/index.d.cts CHANGED
@@ -283,7 +283,7 @@ declare class S3Stream extends S3File {
283
283
  private readonly maxUploadFileSizeRestriction;
284
284
  private readonly s3Limiter;
285
285
  constructor({ maxUploadFileSizeRestriction, concurrencyVideoLimit, ...props }: S3StreamProps);
286
- protected streamObjectFile(fileKey: string, { Range, checkFileExists, abortSignal, }?: {
286
+ getObjectFileStream(fileKey: string, { Range, checkFileExists, abortSignal, }?: {
287
287
  Range?: string;
288
288
  checkFileExists?: boolean;
289
289
  abortSignal?: AbortSignal;
package/dist/index.d.ts CHANGED
@@ -283,7 +283,7 @@ declare class S3Stream extends S3File {
283
283
  private readonly maxUploadFileSizeRestriction;
284
284
  private readonly s3Limiter;
285
285
  constructor({ maxUploadFileSizeRestriction, concurrencyVideoLimit, ...props }: S3StreamProps);
286
- protected streamObjectFile(fileKey: string, { Range, checkFileExists, abortSignal, }?: {
286
+ getObjectFileStream(fileKey: string, { Range, checkFileExists, abortSignal, }?: {
287
287
  Range?: string;
288
288
  checkFileExists?: boolean;
289
289
  abortSignal?: AbortSignal;
package/dist/index.js CHANGED
@@ -1409,7 +1409,7 @@ var S3Stream = class _S3Stream extends S3File {
1409
1409
  this.maxUploadFileSizeRestriction = maxUploadFileSizeRestriction;
1410
1410
  this.s3Limiter = concurrencyVideoLimit ? pLimit(concurrencyVideoLimit) : null;
1411
1411
  }
1412
- streamObjectFile(_0) {
1412
+ getObjectFileStream(_0) {
1413
1413
  return __async(this, arguments, function* (fileKey, {
1414
1414
  Range,
1415
1415
  checkFileExists = true,
@@ -1629,7 +1629,7 @@ var S3Stream = class _S3Stream extends S3File {
1629
1629
  next(Error(`File not found: "${normalizedKey}"`));
1630
1630
  return;
1631
1631
  }
1632
- stream = yield this.streamObjectFile(normalizedKey, {
1632
+ stream = yield this.getObjectFileStream(normalizedKey, {
1633
1633
  abortSignal: abort.signal,
1634
1634
  checkFileExists: false
1635
1635
  });
@@ -1639,9 +1639,9 @@ var S3Stream = class _S3Stream extends S3File {
1639
1639
  return;
1640
1640
  }
1641
1641
  const fileInfo = yield this.fileInfo(normalizedKey);
1642
- const fileName = filename || normalizedKey.split("/").pop() || "download";
1643
1642
  const contentType = fileInfo.ContentType || "application/octet-stream";
1644
1643
  const ext = extname(fileKey).slice(1).toLowerCase();
1644
+ const fileName = filename || normalizedKey.split("/").pop() || `${Date.now()}.${ext}`;
1645
1645
  const inlineTypes = ["text/", "image/", "application/pdf", "video/", "audio/"];
1646
1646
  const canDisplayInline = SUPPORTED_IFRAME_EXTENSIONS.includes(ext) || inlineTypes.some((type) => contentType.startsWith(type));
1647
1647
  res.setHeader("Content-Type", contentType);
@@ -1657,6 +1657,7 @@ var S3Stream = class _S3Stream extends S3File {
1657
1657
  if (cachingAge) {
1658
1658
  res.setHeader("Cache-Control", `public, max-age=${cachingAge}`);
1659
1659
  }
1660
+ res.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Disposition, Content-Length");
1660
1661
  stream.on("error", (err) => {
1661
1662
  var _a3, _b2;
1662
1663
  (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "Stream error", { fileKey: normalizedKey, error: err });
@@ -1731,7 +1732,7 @@ var S3Stream = class _S3Stream extends S3File {
1731
1732
  var _a3, _b2, _c2;
1732
1733
  try {
1733
1734
  if (abort.signal.aborted) return null;
1734
- const stream = yield this.streamObjectFile(fileKey2, { abortSignal: abort.signal });
1735
+ const stream = yield this.getObjectFileStream(fileKey2, { abortSignal: abort.signal });
1735
1736
  if (!stream) {
1736
1737
  (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "File not found", { fileKey: fileKey2 });
1737
1738
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hdriel/aws-utils",
3
- "version": "1.2.3",
3
+ "version": "1.2.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",