123456
const fs = require('fs');const body = req.rawBody;const base64Data = body.replace(/^data:image\/png;base64,/,"");const binaryData = Buffer.from(base64Data, 'base64').toString('binary');fs.writeFileSync("out.png", binaryData, "binary");
12345678910111213141516171819
const fs = require('fs');// ....// callbackfunction getImage(gmail, id, mid, name) { gmail.users.messages.attachments.get( { userId: 'me', id: mid, messageId: id }, (err, res) => { if (err) console.log(err); else { const image = res.data.data.replace(/_/g, '/').replace(/-/g, '+'); fs.writeFileSync(name, Buffer.from(image, 'base64').toString('binary'), 'binary'); } } );}
URARA
乌拉拉大陆
tokyo
Posts
115
Categories
11
Tags
38
linux
javascript / linux
javascript
Update your browser to view this website correctly. Update my browser now
×