Skip to content

Commit

Permalink
Merge pull request #174 from nulib/4349-download-link-update
Browse files Browse the repository at this point in the history
Force download of stitched AV & set expiration to 3 days
  • Loading branch information
mbklein committed Nov 16, 2023
2 parents 05311a8 + 90a28d8 commit c2a2609
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lambdas/get-download-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ module.exports.handler = async (event) => {
const clientParams = {}

const getObjectParams = {
"Bucket": event.bucket,
"Key": event.key
}
Bucket: event.bucket,
Key: event.key,
ResponseContentDisposition: `attachment; filename=${event.disposition}`,
};

const client = new S3Client(clientParams);
const command = new GetObjectCommand(getObjectParams);
const url = await getSignedUrl(client, command, { expiresIn: 3600 });
const url = await getSignedUrl(client, command, { expiresIn: 3600 * 24 * 3 }); // 3 days

return {downloadLink: url}

Expand Down
1 change: 1 addition & 0 deletions src/handlers/get-file-set-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ async function processDownload(doc, email) {
presignedUrlInput: {
bucket: destinationBucket,
key: destinationKey,
disposition: `${fileSetId}.mp4`,
},
sendEmailInput: {
to: email,
Expand Down
4 changes: 2 additions & 2 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ Resources:
SubjectPart: Your {{fileType}} download from Meadow is ready
TextPart: |
Hello,
Your request for {{fileType}} download of {{fileSetLabel}} (file set id: {{fileSetId}}) has been fulfilled. Your download will be available for 24 hours.
Your request for {{fileType}} download of {{fileSetLabel}} (file set id: {{fileSetId}}) has been fulfilled. Your download will be available for 3 days.
The {{fileType}} file can be downloaded from {{downloadLink}}
HtmlPart: |
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
Expand Down Expand Up @@ -809,7 +809,7 @@ Resources:
</a>
</p>
<p style='text-align: center; font-style: italic'>
(Your <a href='{{downloadLink}}'>download</a> will be available for 24 hours)
(Your <a href='{{downloadLink}}'>download</a> will be available for 3 days)
</p>
</td>
</tr>
Expand Down

0 comments on commit c2a2609

Please sign in to comment.