Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d86f54

Browse files
test
1 parent d35073b commit 6d86f54

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

‎functions/save.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@ exports.handler = function(event, context, callback) {
3333
ACL: "public-read",
3434
};
3535
} else {
36+
let base64 = jsondata.data;
37+
let base64data = new Buffer.from(
38+
base64.replace(/^data:image\/\w+;base64,/, ""),
39+
"base64"
40+
);
41+
3642
let filename =
3743
"img/" +
3844
Math.random().toString(36).substring(2, 15) +
3945
Math.random().toString(36).substring(2, 15) +
4046
".jpg";
4147
var params = {
42-
Body: jsondata.data,
48+
Body: base64data,
4349
Bucket: process.env.S3_BUCKET,
4450
Key: filename,
51+
ContentEncoding: "base64",
4552
ContentType: "image/jpeg",
4653
ACL: "public-read",
4754
};

‎public/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ <h2>Result:</h2>
9191
document.querySelector("#image").src = base64data;
9292

9393
// save the image
94-
var data = base64data.replace(/^data:image\/\w+;base64,/, "");
94+
//var data = base64data.replace(/^data:image\/\w+;base64,/, "");
95+
var data = base64data;
9596
let type = "image";
9697
save(data, type);
9798
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /