コード例 #1
0
ファイル: build-images.js プロジェクト: vutran/alfred-pokedex
 fs.mkdirp(utils.SPRITES_DIR, err => {
   if (!err) {
     // download the image
     base64.encode(url, {}, (err2, image) => {
       // write the image to disk
       fs.writeFile(utils.getSpritesPath(id), image, null, () => {
         resolve(true);
       });
     });
   }
 });
コード例 #2
0
ファイル: app.js プロジェクト: ga-dc/class-tweeter
function tweet (listing) {
  if(listing.title && listing.date_description && listing.time_description && listing.url && listing.image_url) {
    if (!listing.url.match("http")) listing.url = "http://generalassemb.ly" + listing.url
    var newStatus = listing.title +  " " + listing.date_description + " " + listing.time_description + " " + listing.url
    base64.encode(listing.image_url, {}, function (err, response) {
      if(err) console.log(err);
      var data = response.toString('base64')
      client.post('/media/upload.json', {media_data: data}, function (err, response) {
        if(!err && response.media_id_string) {
          client.post('/statuses/update.json', {media_ids: response.media_id_string, status: newStatus}, function(err, tweet, response) {
            if(err) console.log(err);
          });
        }
      });
    });
  }
}
コード例 #3
0
 return new Promise((resolve, reject) => {
   encode(urlToEncode, { string: true }, (error, result) => {
     if (error) reject(error);
     if (result) resolve(result);
   });
 });