create new api for drawing random marks

This commit is contained in:
2026-02-24 13:10:19 +05:30
parent 572327b540
commit fb3eca2e64

View File

@@ -42,24 +42,19 @@ const saveGameScore2 = async (req, res) => {
const result = await newGame.save();
// Upload screenshot to S3 if provided
if (screenShot) {
try {
let base64Image = screenShot.split(";base64,").pop();
const buffer = Buffer.from(base64Image, "base64");
let base64Image = screenShot.split(";base64,").pop();
const buffer = Buffer.from(base64Image, "base64");
const uploadParams = {
Bucket: process.env.S3_BUCKET_NAME,
Key: `images/${result._id}.png`,
Body: buffer,
ContentType: "image/png",
};
const uploadParams = {
Bucket: process.env.S3_BUCKET_NAME,
Key: `images/${result._id}.png`,
Body: buffer,
ContentType: "image/png",
};
const s3Response = await s3.upload(uploadParams).promise();
newGame.screenshotUrl = s3Response.Location;
await newGame.save();
} catch (uploadError) {
console.log("Screenshot upload failed, saving without screenshot:", uploadError.message);
// Continue without screenshot - the game data is still saved
}
const s3Response = await s3.upload(uploadParams).promise();
newGame.screenshotUrl = s3Response.Location;
await newGame.save();
}
res.status(200).json({