nevill / danzi Goto Github PK
View Code? Open in Web Editor NEWA uploader middleware for express application.
License: MIT License
A uploader middleware for express application.
License: MIT License
https://github.com/tjfontaine/node-imagick
It has a better performance.
Seems knox or bodyParser doesn't handle it.
Try to use file -Ib filename
to detect the uploaded file mime type.
We should let user define the way to generate the uploaded filename.
Means, user can easily overwrite these two functions.
function generateNameWithExt(file) {
var name = '';
for (var i = 0; i < 32; i++) {
name += Math.floor(Math.random() * 16).toString(16);
}
name += path.extname(file);
return name;
}
function generateNameWithVersion(file, version) {
var extname = path.extname(file);
return path.basename(file, extname) + "-" + version + extname;
}
node-imagemagick depends on imagemagick (and available on $PATH
).
Related to #3.
Need to have a CI system to help in testing.
From #9:
The problem right now is, I did a kind of hack on function res.end, to let the server response as soon as possible, leaving the imagemagick process behind.
I've ran into an issue with this whereby I link to a "versioned" (resized) image immediately after the server responds, but as the image has yet to be resized, the image URL is broken.
The image resizing is done asynchronously from the upload of the original image. Perhaps we need to support a promise-like interface for this.
If there is a timeout happened during S3 upload, a error thrown, we don't catch it anywhere, the whole server gets killed.
75783 ms - Mon, 26 Aug 2013 02:43:44 GMT - - - PUT /api/projects/52149046a1b7c9d84500003b curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5 / -
events.js:72
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at errnoException (net.js:901:11)
at TCP.onread (net.js:556:19)
To see if it's possible to do a easy test with fake-s3
danzi uses the req.files.[file].versions
property to generate thumbnails.
I was looking to add a test (in tlvince@00fa2d2), but couldn't find a way to set the versions property using super{agent,test}#request.attach
(manually adding it to the attachments
property didn't work).
Is there a clean way to do this?
Should be able to pass one axis, e.g. versions: { thumb: [10] }
to resize width and allowing imagemagick to scale the height appropriately.
Consider changing the versions dimensions array to an object for clarity, e.g.:
versions: {
thumb: {
width: 100,
height: 100
}
}
Presumably, im.resize() will fail if the file is not an image.
See also #2.
How about using SHA1 (instead of a random) filenames? That way, we can prevent
duplication and save a write operation.
See: tlvince@e8fa3f6
(Untested with the AWS connector).
See this link.
I think we need to add support for multiple uploads (feel free to correct me if this is already supported).
This comes in two forms: n uploads with different names, and n uploads with the same name (an array of uploads).
Here's a test stub: tlvince@d08c5fb
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.