Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

using temporary file for resized image. and removing the file after s…

…erving the image.
  • Loading branch information...
commit 13f5843125f6e19984ec05645d8734ab5f03fa1c 1 parent a107dac
sam authored
Showing with 35 additions and 0 deletions.
  1. +35 −0 src/tempfile.js
View
35 src/tempfile.js
@@ -0,0 +1,35 @@
+var path = require('path');
+
+var util = require('./util');
+
+var defaultRootDir = '/tmp';
+var defaultPrefix = "tmp-";
+var defaultPostfix = "";
+
+var generateName = function() {
+ return '%s-%s'.f(
+ Date.now()
+ , (Math.random() * 0x100000000 + 1).toString(36));
+};
+
+
+
+var getName = function(prefix, postfix) {
+ if (undefined === prefix) {
+ prefix = defaultPrefix;
+ }
+ if (undefined === postfix) {
+ postfix = defaultPostfix;
+ }
+ return prefix + generateName() + postfix;
+};
+
+var getPath = function(rootDir, prefix, postfix) {
+ if (undefined === rootDir) {
+ rootDir = defaultRootDir;
+ }
+ return path.join(rootDir, getName(prefix, postfix));
+};
+
+exports.getPath = getPath;
+exports.getName = getName;
Please sign in to comment.
Something went wrong with that request. Please try again.