create new api for drawing random marks
This commit is contained in:
@@ -42,6 +42,7 @@ const saveGameScore2 = async (req, res) => {
|
|||||||
const result = await newGame.save();
|
const result = await newGame.save();
|
||||||
// Upload screenshot to S3 if provided
|
// Upload screenshot to S3 if provided
|
||||||
if (screenShot) {
|
if (screenShot) {
|
||||||
|
try {
|
||||||
let base64Image = screenShot.split(";base64,").pop();
|
let base64Image = screenShot.split(";base64,").pop();
|
||||||
const buffer = Buffer.from(base64Image, "base64");
|
const buffer = Buffer.from(base64Image, "base64");
|
||||||
|
|
||||||
@@ -55,6 +56,10 @@ const saveGameScore2 = async (req, res) => {
|
|||||||
const s3Response = await s3.upload(uploadParams).promise();
|
const s3Response = await s3.upload(uploadParams).promise();
|
||||||
newGame.screenshotUrl = s3Response.Location;
|
newGame.screenshotUrl = s3Response.Location;
|
||||||
await newGame.save();
|
await newGame.save();
|
||||||
|
} catch (uploadError) {
|
||||||
|
console.log("Screenshot upload failed, saving without screenshot:", uploadError.message);
|
||||||
|
// Continue without screenshot - the game data is still saved
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
|
|||||||
Reference in New Issue
Block a user