IO-3281 Resolve key issue for downloads.
This commit is contained in:
@@ -103,13 +103,7 @@ const getThumbnailUrls = async (req, res) => {
|
||||
//<Cloudfront_to_lambda>/<hmac with SHA of entire request URI path (with base64 encoded URL if needed), beginning with un-encoded/un-hashed Salt>/<remainder of url - resize params >/< base 64 URL encoded to image path>
|
||||
//When working with documents from Cloudinary, the URL does not include the extension.
|
||||
|
||||
let key;
|
||||
|
||||
if (/\.[^/.]+$/.test(document.key)) {
|
||||
key = document.key;
|
||||
} else {
|
||||
key = `${document.key}.${document.extension.toLowerCase()}`;
|
||||
}
|
||||
let key = keyStandardize(document)
|
||||
// Build the S3 path to the object.
|
||||
const fullS3Path = `s3://${imgproxyDestinationBucket}/${key}`;
|
||||
const base64UrlEncodedKeyString = base64UrlEncode(fullS3Path);
|
||||
@@ -205,7 +199,7 @@ const downloadFiles = async (req, res) => {
|
||||
|
||||
try {
|
||||
for (const doc of data.documents) {
|
||||
const key = doc.key;
|
||||
let key = keyStandardize(doc)
|
||||
let response;
|
||||
try {
|
||||
response = await s3client.send(
|
||||
@@ -388,6 +382,15 @@ const moveFiles = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
const keyStandardize = (doc) => {
|
||||
if (/\.[^/.]+$/.test(doc.key)) {
|
||||
return doc.key;
|
||||
} else {
|
||||
return `${doc.key}.${doc.extension.toLowerCase()}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
generateSignedUploadUrls,
|
||||
getThumbnailUrls,
|
||||
|
||||
Reference in New Issue
Block a user