Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot upload profile image #4186

Closed
kiochan opened this issue Feb 14, 2016 · 2 comments
Closed

cannot upload profile image #4186

kiochan opened this issue Feb 14, 2016 · 2 comments
Assignees
Labels

Comments

@kiochan
Copy link

kiochan commented Feb 14, 2016

Hello,
I'm running NodeBB v0.9.3. on ubuntu 14

I have a problem with uploading of image.
When I'm uploading the image for the profile,
it will show me "error uploading, code : 0"

The follow logs are here:
15/2 08:06 [15188] - info: NodeBB Ready
15/2 08:06 [15188] - info: Enabling 'trust proxy'
15/2 08:06 [15188] - info: NodeBB is now listening on: 0.0.0.0:29131
15/2 08:06 [15188] - info: [plugins/spam-be-gone] Settings loaded
15/2 08:10 [15188] - error: TypeError: path must be a string
at TypeError (native)
at Object.fs.unlink (fs.js:975:11)
at /home/studioasc/chat/src/user/picture.js:210:15
at /home/studioasc/chat/node_modules/async/lib/async.js:52:16
at /home/studioasc/chat/node_modules/async/lib/async.js:696:30
at /home/studioasc/chat/node_modules/async/lib/async.js:167:37
at Immediate._onImmediate (/home/studioasc/chat/node_modules/async/lib/async.js:1206:34)
at processImmediate as _immediateCallback
TypeError: path must be a string
at TypeError (native)
at Object.fs.unlink (fs.js:975:11)
at /home/studioasc/chat/src/user/picture.js:210:15
at /home/studioasc/chat/node_modules/async/lib/async.js:52:16
at /home/studioasc/chat/node_modules/async/lib/async.js:696:30
at /home/studioasc/chat/node_modules/async/lib/async.js:167:37
at Immediate._onImmediate (/home/studioasc/chat/node_modules/async/lib/async.js:1206:34)
at processImmediate as _immediateCallback
15/2 08:10 [15188] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
15/2 08:10 [15188] - info: [app] Database connection closed.
15/2 08:10 [15188] - info: [app] Web server closed to connections.
15/2 08:10 [15188] - info: [app] Shutdown complete.
[cluster] Child Process (15188) has exited (code: 1, signal: null)
[cluster] Spinning up another process...
15/2 08:10 [15252] - info: Time: Mon Feb 15 2016 08:10:55 GMT+0900 (JST)
15/2 08:10 [15252] - info: Initializing NodeBB v0.9.3
15/2 08:10 [15252] - warn: You have no mongo password setup!
15/2 08:10 [15252] - info: [database] Checking database indices.
15/2 08:10 [15252] - warn: [socket.io] Clustering detected, you are advised to configure Redis as a websocket store.

15/2 08:10 [15252] - warn: [plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run ./nodebb reset -p PLUGINNAME to disable it.

nodebb-plugin-markdown
nodebb-plugin-emoji-extended
nodebb-plugin-composer-default
How can i fix this?

@iDevPro
Copy link

iDevPro commented Feb 15, 2016

Me too :(

Install NodeBB from GIT, use mongodb

I try expect file nodebb/src/user/picture.js
And see that:

User.updateCoverPicture = function(data, callback) {
                var tempPath, url, md5sum;

async.waterfall([
    function(next) {
    var size = data.file ? data.file.size : data.imageData.length;

    if (data.file) {
       console.warn('FILE PRESENT'); // my anchor, i get here and return to next function
       return next();
    }

// SKIP THIS BLOCK ? (tempPath = path.join....) ???

md5sum = crypto.createHash('md5');
   md5sum.update(data.imageData);
   md5sum = md5sum.digest('hex');

   console.warn('PATH: ',nconf.get('base_dir'), nconf.get('upload_path'));
   tempPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), md5sum);
   var buffer = new Buffer(data.imageData.slice(data.imageData.indexOf('base64') + 7), 'base64');

   fs.writeFile(tempPath, buffer, {
        encoding: 'base64'
   }, next);

// AND RUN THIS 👍

function(next) {
   console.warn('TEMP PATH:', tempPath); // --> undefined here :)
   file.isFileTypeAllowed(tempPath, next);
},

// AND SO...

function(next) {
   console.warn('TEMP PATH:', tempPath); // --> undefined here :)
   file.isFileTypeAllowed(tempPath, next);
},
function(tempPath, next) {
  console.warn('YAY'); // Not shown :(
  var image = {
      name: 'profileCover',
      path: data.file ? data.file.path : tempPath,
      uid: data.id
  };

  console.warn('PATH2: ', image.path); // Not shown too :(

// RESUME
This issue, can happen by undefined returned for Path :(

@iDevPro
Copy link

iDevPro commented Feb 15, 2016

Fix here:

function(next) {
   file.isFileTypeAllowed(data.file.path, next); // replace to data.file.path :)
},

@julianlam julianlam self-assigned this Feb 15, 2016
@julianlam julianlam added the bug label Feb 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants