removed imgur from core
parent
94588e15f2
commit
378ccc3cb7
@ -1,41 +0,0 @@
|
|||||||
var request = require('request'),
|
|
||||||
winston = require('winston');
|
|
||||||
|
|
||||||
|
|
||||||
(function (imgur) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
imgur.upload = function (clientID, image, type, callback) {
|
|
||||||
var options = {
|
|
||||||
url: 'https://api.imgur.com/3/upload.json',
|
|
||||||
headers: {
|
|
||||||
'Authorization': 'Client-ID ' + clientID
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var post = request.post(options, function (err, req, body) {
|
|
||||||
if(err) {
|
|
||||||
return callback(err, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
var response = JSON.parse(body);
|
|
||||||
|
|
||||||
if(response.success) {
|
|
||||||
callback(null, response.data);
|
|
||||||
} else {
|
|
||||||
callback(new Error(response.data.error.message), null);
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
winston.error('Unable to parse Imgur json response. [' + body +']');
|
|
||||||
callback(e, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
post.form({
|
|
||||||
type: type,
|
|
||||||
image: image
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
}(exports));
|
|
Loading…
Reference in New Issue