Skip to content

Commit

Permalink
Fix URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mrarticuno committed Nov 12, 2023
1 parent 85e376d commit aae1646
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const getSignedUrlPromise = async (ContentType) => {
const signedUrl = await getSignedUrl(s3Client, command, {
expiresIn: 3600,
});
return signedUrl;
return {
url: signedUrl,
fileName,
};
} catch (error) {
console.error('Error uploading file:', error);
throw new Error('Failed to upload file');
Expand Down
13 changes: 8 additions & 5 deletions src/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ const getSignedUrlPromise = async (ContentType) => {
const signedUrl = await getSignedUrl(s3Client, command, {
expiresIn: 3600,
});
return signedUrl;
return {
url: signedUrl,
fileName,
};
} catch (error) {
console.error('Error uploading file:', error);
throw new Error('Failed to upload file');
Expand Down Expand Up @@ -402,10 +405,10 @@ module.exports.requestSubmissionUrl = async (event) => {
}
}

const url = await getSignedUrlPromise(ContentType);
const signedUrl = await getSignedUrlPromise(ContentType);

connection.query('UPDATE Submission SET Filename = ? WHERE Id = ?', [
url.fileName,
signedUrl.fileName,
submissionId,
userEmail,
]);
Expand All @@ -418,8 +421,8 @@ module.exports.requestSubmissionUrl = async (event) => {
statusCode: 200,
body: JSON.stringify({
message: 'Submission url generated successfully',
url,
fileName: url.fileName,
url: signedUrl.url,
fileName: signedUrl.fileName,
}),
};
} catch (error) {
Expand Down

0 comments on commit aae1646

Please sign in to comment.