-2

I'm not sure how to use the tmp package of node correctly. Maybe someone can give me an example

Filename generation

It is possible with this library to generate a unique filename in the specified directory.

var tmp = require('tmp');

tmp.tmpName(function _tempNameGenerated(err, path) {
    if (err) throw err;
    console.log("Created temporary filename: ", path);
});

But what and how do I pass path. As I understand it, it makes sure, that in my desired directory are just unique filenames. So do I have to pass my for example upload directory as path? (But how syntax wise?)

Documentation

Michael Brenndoerfer
  • 3,483
  • 2
  • 39
  • 50

1 Answers1

1

You don't.

You call tmpName, it calls its callback with an error (err, null if there isn't one) and the path.

Inside the callback you do what you want to do with the temporary filename, like write something to it.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302