Skip to content

Commit

Permalink
Update code structure to reference exported function uploadToS3
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshGajabi committed Dec 15, 2023
1 parent be0c5de commit af1a2e3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/controllers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports.createLostRequest = async (req, res, next) => {

try {
if (req.files && req.files.length > 0) {
const uploadPromises = req.files.map(file => uploadToS3('lost-items', file));
const uploadPromises = req.files.map(file => exports.uploadToS3('lost-items', file));
imageUrls = await Promise.all(uploadPromises);
}

Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports.editLostRequest = async (req, res, next) => {
}

if (req.files && req.files.length > 0) {
const uploadPromises = req.files.map(file => uploadToS3('found-items', file));
const uploadPromises = req.files.map(file => exports.uploadToS3('found-items', file));
imageUrls = await Promise.all(uploadPromises);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ module.exports.createFoundRequest = async (req, res, next) => {

try {
if (req.files && req.files.length > 0) {
const uploadPromises = req.files.map(file => uploadToS3('found-items', file));
const uploadPromises = req.files.map(file => exports.uploadToS3('found-items', file));
imageUrls = await Promise.all(uploadPromises);
}

Expand Down Expand Up @@ -177,7 +177,7 @@ module.exports.editFoundRequest = async (req, res, next) => {
}

if (req.files && req.files.length > 0) {
const uploadPromises = req.files.map(file => uploadToS3('found-items', file));
const uploadPromises = req.files.map(file => exports.uploadToS3('found-items', file));
imageUrls = await Promise.all(uploadPromises);
}

Expand Down Expand Up @@ -413,7 +413,7 @@ module.exports.finalHandoff = async (req, res, next) => {
};


async function uploadToS3 (folder, file) {
module.exports.uploadToS3 = async function (folder, file) {
const fileName = `${folder}/${uuidv4()}-${file.originalname}`;

const command = new PutObjectCommand({
Expand Down

0 comments on commit af1a2e3

Please sign in to comment.