mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
changed the file upload to use streams
This commit is contained in:
@@ -59,7 +59,6 @@
|
||||
</div>
|
||||
<div id="user-actions" class="container">
|
||||
<a id="add-friend-btn" href="#" class="btn">Add Friend</a>
|
||||
<a id="send-message-btn" href="#" class="btn">Send Message</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -88,16 +87,15 @@ var theirid = '{theirid}';
|
||||
|
||||
var editLink = $('#editLink');
|
||||
var addFriendBtn = $('#add-friend-btn');
|
||||
var sendMessageBtn = $('#send-message-btn');
|
||||
|
||||
|
||||
if( yourid !== theirid) {
|
||||
editLink.hide();
|
||||
addFriendBtn.show();
|
||||
sendMessageBtn.show();
|
||||
}
|
||||
else {
|
||||
addFriendBtn.hide();
|
||||
sendMessageBtn.hide();
|
||||
|
||||
}
|
||||
|
||||
addFriendBtn.on('click', function() {
|
||||
@@ -109,9 +107,7 @@ var theirid = '{theirid}';
|
||||
return false;
|
||||
});
|
||||
|
||||
sendMessageBtn.on('click', function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -136,7 +136,37 @@ var user = require('./../user.js'),
|
||||
|
||||
console.log('trying to upload to : '+ global.configuration['ROOT_DIRECTORY'] + uploadPath);
|
||||
|
||||
fs.rename(
|
||||
var is = fs.createReadStream(tempPath);
|
||||
var os = fs.createWriteStream(global.configuration['ROOT_DIRECTORY'] + uploadPath);
|
||||
|
||||
is.pipe(os);
|
||||
|
||||
is.on('end', function(){
|
||||
fs.unlinkSync(tempPath);
|
||||
|
||||
var imageUrl = config.upload_url + filename;
|
||||
|
||||
res.send({
|
||||
path: imageUrl
|
||||
});
|
||||
|
||||
user.setUserField(uid, 'uploadedpicture', imageUrl);
|
||||
user.setUserField(uid, 'picture', imageUrl);
|
||||
|
||||
});
|
||||
|
||||
os.on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*util.pump(is, os, function() {
|
||||
fs.unlinkSync('source_file');
|
||||
});*/
|
||||
|
||||
|
||||
/*fs.rename(
|
||||
tempPath,
|
||||
global.configuration['ROOT_DIRECTORY'] + uploadPath,
|
||||
function(error) {
|
||||
@@ -158,7 +188,7 @@ var user = require('./../user.js'),
|
||||
user.setUserField(uid, 'picture', imageUrl);
|
||||
|
||||
}
|
||||
);
|
||||
);*/
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +241,9 @@ var user = require('./../user.js'),
|
||||
});
|
||||
|
||||
function api_method(req, res) {
|
||||
console.log("fail "+req.params.section);
|
||||
|
||||
|
||||
|
||||
var callerUID = req.user?req.user.uid : 0;
|
||||
|
||||
if (!req.params.section && !req.params.username) {
|
||||
|
||||
@@ -372,6 +372,15 @@ var config = require('../config.js'),
|
||||
});
|
||||
}
|
||||
|
||||
User.removeFriend = function(uid, friendid, callback) {
|
||||
RDB.srem('user:'+uid+':friends', friendid, function(err, data){
|
||||
if(err === null)
|
||||
callback(data);
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
User.exists = function(username, callback) {
|
||||
User.get_uid_by_username(username, function(exists) {
|
||||
exists = !!exists;
|
||||
|
||||
Reference in New Issue
Block a user