pangea-server 3.3.152 → 3.3.153

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.
@@ -20,6 +20,17 @@ const s3 = new aws_sdk_1.default.S3({
20
20
  secretAccessKey: (0, env_helpers_1.getEnvStr)('DIGITAL_OCEAN_SPACES_SECRET_KEY'),
21
21
  });
22
22
  const expiresTime = 60 * 10;
23
+ const mimeExtensions = {
24
+ 'image/png': 'png',
25
+ 'image/jpeg': 'jpg',
26
+ 'image/webp': 'webp',
27
+ 'image/gif': 'gif',
28
+ 'image/svg+xml': 'svg',
29
+ 'application/pdf': 'pdf',
30
+ 'video/mp4': 'mp4',
31
+ 'video/webm': 'webm',
32
+ 'video/quicktime': 'mov',
33
+ };
23
34
  class FileStorage {
24
35
  static GenerateDownloadUrl(fileName) {
25
36
  return s3.getSignedUrlPromise('getObject', { Bucket: bucketName, Key: fileName, Expires: expiresTime });
@@ -91,7 +102,9 @@ class FileStorage {
91
102
  exports.FileStorage = FileStorage;
92
103
  // internal functions
93
104
  function getGeneralUploadParams(config) {
94
- const fileName = `${config.folder}/${(0, random_helpers_1.getRandomString)('short')}/${config.fileType}`;
105
+ const extension = mimeExtensions[config.fileType];
106
+ const suffix = extension ? `.${extension}` : '';
107
+ const fileName = `${config.folder}/${(0, random_helpers_1.getRandomString)('short')}${suffix}`;
95
108
  return { Bucket: bucketName, Key: fileName, ContentType: config.fileType, ACL: 'private' };
96
109
  }
97
110
  async function uploadFile(body, config) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.152",
4
+ "version": "3.3.153",
5
5
  "engines": {
6
6
  "node": "22.14.0"
7
7
  },