How to use the imgur.setClientId 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('---------------------------------------------------')
    })
github FruitieX / teleirc / src / tg / imgur-utils.js View on Github external
const configDir = path.dirname(argv.c || path.join(os.homedir(), '.teleirc', 'config.js'));
const linkCacheFilePath = path.join(configDir, 'imgurLinkCache.json');

let linkCacheData = [];
try {
    if (fs.pathExistsSync(linkCacheFilePath)) {
        linkCacheData = fs.readJsonSync(linkCacheFilePath);
    }
} catch (error) {
    logger.error(error);
}
const linkCache = new LRU(config.imgurLinkCacheSize, linkCacheData);

if (config.uploadToImgur) {
    imgur.setClientId(config.imgurClientId);
}

exports.uploadToImgur = function(fileId, config, tg, callback) {

    /* Kind of a hack to get an async function to complete with a callback. */
    async function impl() {

        try {
            const downloadDirPath = await fs.mkdtemp(path.join(os.tmpdir(), 'teleirc-'));

            const filePath = await tg.downloadFile(fileId, downloadDirPath);

            const fileContentBuffer = await fs.readFile(filePath);
            const md5Hash = md5(fileContentBuffer);

            if (!linkCache.has(md5Hash)) {
github Hydrog3n / upload-screenshot / services / imgur.js View on Github external
Imgur.prototype.upload = function(path,callback) {

  img.setClientId(this.service.clientId);

  img.uploadFile(path)
    .then(function (json) {
    callback(json.data.link);
    })
    .catch(function (err) {
      console.error(err);
      notifier.notify({
        'title': 'Error !',
        'message': 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}`);
    });
  
}
github DIYgod / RSSHub / routes / telegram / stickerpack.js View on Github external
const axios = require('../../utils/axios');
const config = require('../../config');
const logger = require('../../utils/logger');
const sharp = require('sharp');
const imgur = require('imgur');
const fs = require('fs');

if (config.imgur && config.imgur.clientId) {
    imgur.setClientId(config.imgur.clientId);
}

module.exports = async (ctx) => {
    const name = ctx.params.name;
    const cacheDays = 30;

    const response = await axios({
        method: 'get',
        url: `https://api.telegram.org/bot${config.telegram.token}/getStickerSet?name=${name}`,
    });

    const data = response.data.result;

    const links = await Promise.all(
        data.stickers.map(async (item) => {
            const key = `telegramstickerpack${item.file_id}`;
github ewnd9 / record-desktop / src / main / utils.js View on Github external
import { dialog } from 'electron';
import pify from 'pify';
import prettyBytes from 'pretty-bytes';

import fs from 'fs';

const stat = pify(fs.stat);
const readdir = pify(fs.readdir);

import imgur from 'imgur';
imgur.setClientId('a9e8e4383e6dfa2');

import { nativeImage, clipboard } from 'electron';
import { notify } from './logger';

export openFile from './unix-utils/wrappers/xdg-open';

export const selectFolder = () => {
  const result = dialog.showOpenDialog({ properties: [ 'openDirectory' ] });
  return result && result[0];
};

export const getFiles = folder => {
  if (!folder) {
    return Promise.resolve([]);
  }

imgur

Unofficial JavaScript library for Imgur

AGPL-3.0
Latest version published 11 months ago

Package Health Score

64 / 100
Full package analysis