Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function () {
imgur.setClientId(this.config.imgur)
const screenshot = await this.driver.takeScreenshot()
return imgur.uploadBase64(screenshot.toString('base64'))
/* eslint-disable no-console */
.then((json) => {
console.log('---------------------------------------------------')
console.log('SCREEENSHOT URL:', json.data.link)
console.log('---------------------------------------------------')
return json.data
})
.catch((error) => {
console.log('---------------------------------------------------')
console.error('Failed to save screenshot:', error.message)
console.log('---------------------------------------------------')
})
/* eslint-enable no-console */
}
.then((event) => {
const newEventInfo = req.body;
if (newEventInfo.base64Image) {
// send it up to imgur
imgur.uploadBase64(newEventInfo.base64Image)
.then((imgurResponse) => {
newEventInfo.eventPictureUri = imgurResponse.data.link;
delete newEventInfo.base64Image;
event.update(newEventInfo)
.then(event => res.json(event));
})
.catch((err) => {
res.json({ message: 'error updating user' });
console.error(err.message);
});
} else {
event.updateEvent(newEventInfo)
.then((event) => res.json(event));
}
})
.catch(err => {
.then(conflictingUser => {
if (conflictingUser && conflictingUser.id !== user.id) {
return next(new HttpError(409, 'Username already taken'));
}
// newUser = get updated properties from user
const newUserInfo = req.body;
// if we recieved a new base64 encoded profile profile picture
if (newUserInfo.base64Image) {
// send it up to imgur
imgur.uploadBase64(newUserInfo.base64Image)
.then((imgurResponse) => {
newUserInfo.profilePictureUri = imgurResponse.data.link;
delete newUserInfo.base64Image;
user.update(newUserInfo)
.then(user => {
res.json(newUserInfo);
});
})
.catch((err) => {
res.json({ message: 'error updating user' });
console.error(err.message);
});
} else {
user.update(newUserInfo)
.then(user => res.json(newUserInfo));
}
.then((group) => {
if (req.body.encodedGroupPic) {
imgur.uploadBase64(req.body.encodedGroupPic)
.then((imgurResponse) => {
const groupPictureUri = imgurResponse.data.link;
group.update({ groupPictureUri })
.then(group => {
console.log('updated group:', group);
res.json(group);
});
})
.catch((err) => {
res.json({ message: 'error updating user' });
console.error(err.message);
});
}
})
.catch(err => {
function saveToImgur(img) {
addMessage("Uploading screenshot...");
var imgur = require('imgur');
imgur.setClientId('ba8f73761b94a1d');
imgur.uploadBase64(img)
.then(json => {
if(json.data.error) {
addMessage(`Error uploading image: ${json.data.error.message}`);
} else {
logger.info(`Delete link for uploaded image is http://imgur.com/delete/${json.data.deletehash}`);
addMessage(`Screenshot uploaded to <a href="${json.data.link}" class="opn-link">${json.data.link}</a>`);
}
})
.catch(err => {
addMessage(`Error uploading image: ${err}`);
});
}