mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
if imgur client id is not set but local file uploads are enabled use that
This commit is contained in:
@@ -94,9 +94,8 @@ define(['taskbar'], function(taskbar) {
|
|||||||
|
|
||||||
var postContainer = $(composerTemplate[0]);
|
var postContainer = $(composerTemplate[0]);
|
||||||
|
|
||||||
if(config.imgurClientIDSet) {
|
if(config.allowFileUploads || config.imgurClientIDSet)
|
||||||
initializeFileReader(post_uuid);
|
initializeFileReader(post_uuid);
|
||||||
}
|
|
||||||
|
|
||||||
var postData = composer.posts[post_uuid],
|
var postData = composer.posts[post_uuid],
|
||||||
titleEl = postContainer.find('.title'),
|
titleEl = postContainer.find('.title'),
|
||||||
|
|||||||
38
src/posts.js
38
src/posts.js
@@ -360,24 +360,26 @@ var db = require('./database'),
|
|||||||
|
|
||||||
Posts.uploadPostImage = function(image, callback) {
|
Posts.uploadPostImage = function(image, callback) {
|
||||||
|
|
||||||
if(!meta.config.imgurClientID) {
|
if(meta.config.imgurClientID) {
|
||||||
return callback('imgurClientID not set', null);
|
if(!image) {
|
||||||
}
|
return callback('invalid image', null);
|
||||||
|
|
||||||
if(!image) {
|
|
||||||
return callback('invalid image', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) {
|
|
||||||
if(err) {
|
|
||||||
callback(err.message, null);
|
|
||||||
} else {
|
|
||||||
callback(null, {
|
|
||||||
url: data.link,
|
|
||||||
name: image.name
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) {
|
||||||
|
if(err) {
|
||||||
|
callback(err.message, null);
|
||||||
|
} else {
|
||||||
|
callback(null, {
|
||||||
|
url: data.link,
|
||||||
|
name: image.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (meta.config.allowFileUploads) {
|
||||||
|
Posts.uploadPostFile(image, callback);
|
||||||
|
} else {
|
||||||
|
callback('Uploads are disabled!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Posts.uploadPostFile = function(file, callback) {
|
Posts.uploadPostFile = function(file, callback) {
|
||||||
@@ -400,7 +402,7 @@ var db = require('./database'),
|
|||||||
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename);
|
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename);
|
||||||
|
|
||||||
fs.writeFile(uploadPath, buffer, function (err) {
|
fs.writeFile(uploadPath, buffer, function (err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback(err.message, null);
|
callback(err.message, null);
|
||||||
} else {
|
} else {
|
||||||
callback(null, {
|
callback(null, {
|
||||||
|
|||||||
Reference in New Issue
Block a user