Skip to content

Commit

Permalink
Update prepareAssetUpload.js - log possible errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cami-espinozaq authored Nov 21, 2023
1 parent 5d51bae commit fe7850d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/backend/prepareAssetUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ export const handler = async (event) => {
Key: `data/assets/${filename}`,
}

console.log("prepareAssetUpload params", params)

try {
await s3.headObject(params).promise()
return respond.error(409, 'Asset already exists.', { exists: true })
} catch (_error) {
// Asset does not exist, which is good. Just continue.
}

console.log("headObject works")

const uploadUrl = s3.getSignedUrl('putObject', params)

console.log("uploadUrl is", uploadUrl)
return respond.json(200, { uploadUrl })
}

0 comments on commit fe7850d

Please sign in to comment.