How to use the imgur.uploadBase64 function in imgur

To help you get started, we’ve selected a few imgur examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tipsi / tipsi-appium-helper / src / plugins / screenshot.js View on Github external
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 */
}
github preposterousCloud / open-door / server / controllers / Event.js View on Github external
.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 => {
github preposterousCloud / open-door / server / controllers / User.js View on Github external
.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));
        }
github preposterousCloud / open-door / server / controllers / Group.js View on Github external
.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 => {
github briansd9 / exile-diary / main.js View on Github external
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 =&gt; {
      addMessage(`Error uploading image: ${err}`);
    });
  
}

imgur

Unofficial JavaScript library for Imgur

AGPL-3.0
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis