feature/IO-2282-VSSTA-Integration:
- Clean up imgproxy-media.js
This commit is contained in:
@@ -50,17 +50,19 @@ const generateSignedUploadUrls = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.log("imgproxy-upload-success", "DEBUG", req.user?.email, jobid, { signedUrls });
|
logger.log("imgproxy-upload-success", "DEBUG", req.user?.email, jobid, { signedUrls });
|
||||||
res.json({
|
|
||||||
|
return res.json({
|
||||||
success: true,
|
success: true,
|
||||||
signedUrls
|
signedUrls
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(400).json({
|
logger.log("imgproxy-upload-error", "ERROR", req.user?.email, jobid, {
|
||||||
success: false,
|
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
logger.log("imgproxy-upload-error", "ERROR", req.user?.email, jobid, {
|
|
||||||
|
return res.status(400).json({
|
||||||
|
success: false,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
@@ -134,7 +136,7 @@ const getThumbnailUrls = async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(proxiedUrls);
|
return res.json(proxiedUrls);
|
||||||
//Iterate over them, build the link based on the media type, and return the array.
|
//Iterate over them, build the link based on the media type, and return the array.
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("imgproxy-thumbnails-error", "ERROR", req.user?.email, jobid, {
|
logger.log("imgproxy-thumbnails-error", "ERROR", req.user?.email, jobid, {
|
||||||
@@ -143,7 +145,8 @@ const getThumbnailUrls = async (req, res) => {
|
|||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
res.status(400).json({ message: error.message, stack: error.stack });
|
|
||||||
|
return res.status(400).json({ message: error.message, stack: error.stack });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -169,9 +172,9 @@ const downloadFiles = async (req, res) => {
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const passthrough = new stream.PassThrough();
|
const passThrough = new stream.PassThrough();
|
||||||
|
|
||||||
archiveStream.pipe(passthrough);
|
archiveStream.pipe(passThrough);
|
||||||
|
|
||||||
for (const key of data.documents.map((d) => d.key)) {
|
for (const key of data.documents.map((d) => d.key)) {
|
||||||
const response = await s3client.send(
|
const response = await s3client.send(
|
||||||
@@ -192,7 +195,7 @@ const downloadFiles = async (req, res) => {
|
|||||||
client: s3client,
|
client: s3client,
|
||||||
queueSize: 4, // optional concurrency configuration
|
queueSize: 4, // optional concurrency configuration
|
||||||
leavePartsOnError: false, // optional manually handle dropped parts
|
leavePartsOnError: false, // optional manually handle dropped parts
|
||||||
params: { Bucket: imgproxyDestinationBucket, Key: archiveKey, Body: passthrough }
|
params: { Bucket: imgproxyDestinationBucket, Key: archiveKey, Body: passThrough }
|
||||||
});
|
});
|
||||||
|
|
||||||
parallelUploads3.on("httpUploadProgress", (progress) => {
|
parallelUploads3.on("httpUploadProgress", (progress) => {
|
||||||
@@ -200,6 +203,7 @@ const downloadFiles = async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await parallelUploads3.done();
|
await parallelUploads3.done();
|
||||||
|
|
||||||
//Generate the presigned URL to download it.
|
//Generate the presigned URL to download it.
|
||||||
const presignedUrl = await getSignedUrl(
|
const presignedUrl = await getSignedUrl(
|
||||||
s3client,
|
s3client,
|
||||||
@@ -207,7 +211,7 @@ const downloadFiles = async (req, res) => {
|
|||||||
{ expiresIn: 360 }
|
{ expiresIn: 360 }
|
||||||
);
|
);
|
||||||
|
|
||||||
res.json({ success: true, url: presignedUrl });
|
return res.json({ success: true, url: presignedUrl });
|
||||||
//Iterate over them, build the link based on the media type, and return the array.
|
//Iterate over them, build the link based on the media type, and return the array.
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("imgproxy-thumbnails-error", "ERROR", req.user?.email, jobId, {
|
logger.log("imgproxy-thumbnails-error", "ERROR", req.user?.email, jobId, {
|
||||||
@@ -216,7 +220,8 @@ const downloadFiles = async (req, res) => {
|
|||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
res.status(400).json({ message: error.message, stack: error.stack });
|
|
||||||
|
return res.status(400).json({ message: error.message, stack: error.stack });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -262,14 +267,15 @@ const deleteFiles = async (req, res) => {
|
|||||||
ids: result.filter((t) => !t.error).map((d) => d.id)
|
ids: result.filter((t) => !t.error).map((d) => d.id)
|
||||||
});
|
});
|
||||||
|
|
||||||
res.json({ errors, deleteMutationResult });
|
return res.json({ errors, deleteMutationResult });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("imgproxy-delete-files-error", "ERROR", req.user.email, null, {
|
logger.log("imgproxy-delete-files-error", "ERROR", req.user.email, null, {
|
||||||
ids,
|
ids,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
res.status(400).json({ message: error.message, stack: error.stack });
|
|
||||||
|
return res.status(400).json({ message: error.message, stack: error.stack });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -334,14 +340,16 @@ const moveFiles = async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const client = req.userGraphQLClient;
|
const client = req.userGraphQLClient;
|
||||||
|
|
||||||
if (mutations !== "") {
|
if (mutations !== "") {
|
||||||
const mutationResult = await client.request(`mutation {
|
const mutationResult = await client.request(`mutation {
|
||||||
${mutations}
|
${mutations}
|
||||||
}`);
|
}`);
|
||||||
res.json({ errors, mutationResult });
|
|
||||||
} else {
|
return res.json({ errors, mutationResult });
|
||||||
res.json({ errors: "No images were successfully moved on remote server. " });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res.json({ errors: "No images were successfully moved on remote server. " });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("imgproxy-move-files-error", "ERROR", req.user.email, null, {
|
logger.log("imgproxy-move-files-error", "ERROR", req.user.email, null, {
|
||||||
documents,
|
documents,
|
||||||
@@ -349,7 +357,8 @@ const moveFiles = async (req, res) => {
|
|||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
res.status(400).json({ message: error.message, stack: error.stack });
|
|
||||||
|
return res.status(400).json({ message: error.message, stack: error.stack });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user