@internetderdinge/api 1.229.8 → 1.229.9

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.
@@ -2,8 +2,6 @@
2
2
  import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
3
3
  import { Upload } from "@aws-sdk/lib-storage";
4
4
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
5
- import multer from "multer";
6
- import multerS3 from "multer-s3";
7
5
  import fs from "fs";
8
6
  import request from "request";
9
7
  const s3 = new S3Client({
@@ -52,20 +50,6 @@ export const fileFilter = (req, file, cb) => {
52
50
  cb(new Error("Invalid file type, only JPEG and PNG is allowed!"), false);
53
51
  }
54
52
  };
55
- export const uploadFile = multer({
56
- storage: multerS3({
57
- s3: s3,
58
- bucket: process.env.AWS_S3_BUCKET_NAME,
59
- contentType: multerS3.AUTO_CONTENT_TYPE,
60
- acl: "public-read",
61
- metadata(req, file, cb) {
62
- cb(null, { fieldName: file.fieldname });
63
- },
64
- key(req, file, cb) {
65
- cb(null, `${Date.now().toString()}-${file.originalname}`);
66
- },
67
- }),
68
- });
69
53
  const getPhoto = async (photoId, res) => {
70
54
  try {
71
55
  const params = {
@@ -116,7 +100,6 @@ const getPhotoFromUserImage = async (photoId, res) => {
116
100
  }
117
101
  };
118
102
  export default {
119
- uploadFile,
120
103
  uploadImage,
121
104
  getPhoto,
122
105
  getPhotoFromUserImage,
@@ -5,7 +5,7 @@ import AWS from "aws-sdk";
5
5
  import { deviceKindHasFeature } from "../utils/deviceUtils";
6
6
  import ApiError from "../utils/ApiError";
7
7
  import { getAuth0Token } from "../accounts/auth0.service";
8
- import { uploadImage, getSignedFileUrl, } from "../files/upload.service";
8
+ import { uploadImage, getSignedFileUrl } from "../files/upload.service";
9
9
  import { compareImages } from "../utils/comparePapers.service";
10
10
  import IotDevice from "./iotdevice.model";
11
11
  import { fileTypeFromBuffer } from "file-type";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetderdinge/api",
3
- "version": "1.229.8",
3
+ "version": "1.229.9",
4
4
  "description": "Shared OpenIoT API modules",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -68,7 +68,6 @@
68
68
  "moment-timezone": "^0.6.0",
69
69
  "morgan": "^1.10.1",
70
70
  "multer": "^2.0.2",
71
- "multer-s3": "^3.0.1",
72
71
  "multiparty": "~4.2.3",
73
72
  "node-uuid": "~1.4.8",
74
73
  "nodemailer": "^8.0.1",
@@ -3,7 +3,6 @@ import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
3
3
  import { Upload } from "@aws-sdk/lib-storage";
4
4
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
5
5
  import multer from "multer";
6
- import multerS3 from "multer-s3";
7
6
  import fs from "fs";
8
7
  import request from "request";
9
8
 
@@ -82,21 +81,6 @@ export const fileFilter = (
82
81
  }
83
82
  };
84
83
 
85
- export const uploadFile = multer({
86
- storage: multerS3({
87
- s3: s3,
88
- bucket: process.env.AWS_S3_BUCKET_NAME!,
89
- contentType: multerS3.AUTO_CONTENT_TYPE,
90
- acl: "public-read",
91
- metadata(req, file, cb) {
92
- cb(null, { fieldName: file.fieldname });
93
- },
94
- key(req, file, cb) {
95
- cb(null, `${Date.now().toString()}-${file.originalname}`);
96
- },
97
- }),
98
- });
99
-
100
84
  const getPhoto = async (
101
85
  photoId: string,
102
86
  res: Express.Response,
@@ -161,7 +145,6 @@ const getPhotoFromUserImage = async (
161
145
  };
162
146
 
163
147
  export default {
164
- uploadFile,
165
148
  uploadImage,
166
149
  getPhoto,
167
150
  getPhotoFromUserImage,
@@ -5,11 +5,7 @@ import AWS from "aws-sdk";
5
5
  import { deviceKindHasFeature } from "../utils/deviceUtils";
6
6
  import ApiError from "../utils/ApiError";
7
7
  import { getAuth0Token } from "../accounts/auth0.service";
8
- import {
9
- uploadFile,
10
- uploadImage,
11
- getSignedFileUrl,
12
- } from "../files/upload.service";
8
+ import { uploadImage, getSignedFileUrl } from "../files/upload.service";
13
9
  import { compareImages } from "../utils/comparePapers.service";
14
10
  import IotDevice from "./iotdevice.model";
15
11
  import { fileTypeFromBuffer } from "file-type";