0

I'm working with mongoose-thumbnail to get an thumbnail of a image I upload, I done it exactly as in the github mongoose-thumbnail example and it works very well, below is my code

var mongoose = require('mongoose');
var thumbnailPluginLib = require('mongoose-thumbnail');
var path = require('path');
var thumbnailPlugin = thumbnailPluginLib.thumbnailPlugin;
var make_upload_to_model = thumbnailPluginLib.make_upload_to_model;
var uploads_base = path.join(__dirname, "uploads");
var uploads = path.join(uploads_base, "u");

var Schema = mongoose.Schema;

var ApplicationSchema = new Schema({
    appName: String,
    appTempPath:String,
    userId : String,
    status : String,
    templateId: String,
    appSettings:[{header: String, color: String, font: String, fontSize: Number, backImg: String}]
});

ApplicationSchema.plugin(thumbnailPlugin, {
  name: "appIcon",
    inline: true,
    upload_to: make_upload_to_model(uploads, 'appIcon')
});

var Application = mongoose.model('Application', ApplicationSchema);

My problem is how do I find the "uploads" and "u" directories?? I can't find it anywhere in my directory, Please help.

shamila
  • 1,280
  • 6
  • 20
  • 45

1 Answers1

1

It should be in the script_current_directory/uploads/u but it's not? What does console.log(uploads) say? How about console.log(make_upload_to_model(uploads, 'appIcon'))

I'm not sure if your library creates directories that don't exist. If all else fails, you can change the uploads directory or name to something arbitrary like XYZXYZXYZ and do a find . -name "XYZXYZXYZ" and it should turn up.

"the __dirname` keyword contains the path to the root directory of the currently executing script."

  • Paste the output of those console.logs and I'll have a look - if it's a nonexistent location, I'd just make it and try again and see what happens. – Keefe Roedersheimer Sep 10 '15 at 04:16
  • for console.log(uploads) : /home/shamil/Project/madeEasy/api/models/uploads/u for console.log(make_upload_to_model(uploads, 'appIcon')): [Function] After replacing "uploads" as XYZXYZXYZ: /home/shamil/Project/madeEasy/api/models/XYZXYZXYZ/u – shamila Sep 10 '15 at 04:19
  • 1
    and those directories don't exist or they are empty? if they don't exist do mkdir -p /home/shamil/Project/madeEasy/api/models/uploads/u if they do exist, what is inside them? – Keefe Roedersheimer Sep 10 '15 at 04:25
  • so mkdir -p those directories and I hope that's the end of the story :) I'm surprised you didn't get any errors like ENOENT or something from node. – Keefe Roedersheimer Sep 10 '15 at 04:33