-
-
Save DanyF-github/7afbf7dbc7fb1a3d6316e9c3f9c4e757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server/src/graphql/s3.js | |
... | |
const presignDocument = async (_, { fileName, isPublic, token }, __, ___) => { | |
// This token comes from the passwordless login | |
if (!token) { | |
throw new Error(NOT_AUTHENTICATED); | |
} | |
try { | |
// identify the student | |
const data = jwt.verify(token, accessTokenSecret); | |
console.info( | |
`Student with id ${data.id} is presigning filename ${fileName}` | |
); | |
// presign the post requests | |
const uploadData = await s3.presignedPostDocument(fileName, isPublic); | |
// return the response as a stringified JSON | |
return JSON.stringify(uploadData); | |
} catch (err) { | |
console.log('An error ocurred when presigning document:', err); | |
throw new Error(INTERNAL_ERROR); | |
} | |
}; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment