Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #156 from bengourley/master

Look for more potential tmp dir locations
  • Loading branch information...
commit 9ca2b4d9a6f928b37d4beb646ad1c847a6247f0c 2 parents dd8dd7a + 7b6bbe5
@felixge authored
View
2  Readme.md
@@ -179,7 +179,7 @@ __incomingForm.encoding = 'utf-8'__
The encoding to use for incoming form fields.
-__incomingForm.uploadDir = process.env.TMP || '/tmp' || process.cwd()__
+__incomingForm.uploadDir = process.env.TMP || process.env.TMPDIR || process.env.TEMP || '/tmp' || process.cwd()__
The directory for placing file uploads in. You can move them later on using
`fs.rename()`. The default directory is picked at module load time depending on
View
12 lib/incoming_form.js
@@ -10,12 +10,12 @@ var util = require('./util'),
EventEmitter = require('events').EventEmitter,
Stream = require('stream').Stream;
-function IncomingForm(opts) {
+function IncomingForm(opts) {
if (!(this instanceof IncomingForm)) return new IncomingForm;
EventEmitter.call(this);
opts=opts||{};
-
+
this.error = null;
this.ended = false;
@@ -38,7 +38,13 @@ util.inherits(IncomingForm, EventEmitter);
exports.IncomingForm = IncomingForm;
IncomingForm.UPLOAD_DIR = (function() {
- var dirs = [process.env.TMP, '/tmp', process.cwd()];
+ var dirs = [
+ process.env.TMP,
+ process.env.TMPDIR,
+ process.env.TEMP,
+ '/tmp',
+ process.cwd()
+ ];
for (var i = 0; i < dirs.length; i++) {
var dir = dirs[i];
var isDirectory = false;
View
7 test/legacy/simple/test-incoming-form.js
@@ -29,7 +29,12 @@ test(function constructor() {
assert.strictEqual(form.type, null);
assert.strictEqual(form.headers, null);
assert.strictEqual(form.keepExtensions, false);
- assert.strictEqual(form.uploadDir, '/tmp');
+ // Can't assume dir === '/tmp' for portability
+ // assert.strictEqual(form.uploadDir, '/tmp');
+ // Make sure it is a directory instead
+ assert.doesNotThrow(function () {
+ assert(fs.statSync(form.uploadDir).isDirectory());
+ });
assert.strictEqual(form.encoding, 'utf-8');
assert.strictEqual(form.bytesReceived, null);
assert.strictEqual(form.bytesExpected, null);
Please sign in to comment.
Something went wrong with that request. Please try again.