sails.js

Node.js: file upload buffers in memory and memory not freed up after upload is done

我与影子孤独终老i 提交于 2020-01-06 19:40:23
问题 Using Sails.js to upload images to Azure with this code: req.file('picture').upload({ adapter: require('skipper-azure'), key: storageAccount, secret: accessKey, container: 'default' }, function(err, files) { if(!err) { return res.json(cdn + files[0].fd); } else { return res.send(err); } }); I have 2 problems: Files are buffered to memory instead of being streamed The memory is not freed-up when file upload is done, is it a Node.js problem, Sails.js', or my problem? UPDATE When I upload a

Block function whilst waiting for response

六月ゝ 毕业季﹏ 提交于 2020-01-06 18:30:23
问题 I've got a NodeJS app i'm building (using Sails, but i guess that's irrelevant). In my action, i have a number of requests to other services, datasources etc that i need to load up. However, because of the huge dependency on callbacks, my code is still executing long after the action has returned the HTML. I must be missing something silly (or not quite getting the whole async thing) but how on earth do i stop my action from finishing until i have all my data ready to render the view?! Cheers

Assets not loading in sails.js app

不打扰是莪最后的温柔 提交于 2020-01-06 14:48:32
问题 I moved from Arch Linux to Windows 7. I've installed nodejs, npm, sails, grunt. I created a new sails project with sails new <name> and started it with sails lift . My assets will be not compiled or injected by sails. .tmp/public does not exist, too. Maybe someone can help me out? 回答1: Check out this issue https://github.com/balderdashy/sails/issues/3013 Its probably that Grunt is defaulting to False, which means the grunt work flow is not building your assets or creating the public web

SailsJS to Phonegap?

时光毁灭记忆、已成空白 提交于 2020-01-06 14:15:52
问题 I'm trying to create a Phonegap project from SailsJS project. As i found out so far, command "sails build" should generate www folder with files to import to Phonegap. I've tried that, but i get www folder without index file, views,.. It looks like custom grunfile is needed to get appropriate www folder content. The problem is, i don't know how to build it. It would be great if somebody could provide that file... I'm sure it would be very helpful for many... Similar problem has been described

Get total count in Sails JS blueprint API

风流意气都作罢 提交于 2020-01-06 03:23:13
问题 Can I use pagination or limit + skip that has a return "total page" or "total count" in sails js? 回答1: I guess you mean when you use sails blueprint api methods? Unfortunately in current sails version (v0.11.3) you can't. You must send another request for counting. That blueprint method also don't exist in current sails version, but you can use "sails-hook-blueprint-count" package which enable count method with filtering on all defined models. "sails-hook-blueprint-count" package is available

How to cancel sails.js lift with a hook

拈花ヽ惹草 提交于 2020-01-06 02:29:29
问题 I need to perform certain initialization tasks using promises when lifting my Sails.js app. If these tasks fail in any way, the app should not continue lifting and must log an error. In addition, these tasks may not complete in a finite, predefined time (see the hook definition). However, the hook system only allows to call cb() when the hook has successfully completed, and there seems not to be any way in which I can make the app: crash, without a timeout (hook:X:error) not able to continue

How to get notified about external changes in a mongo collection with sails?

a 夏天 提交于 2020-01-06 02:17:05
问题 I am developing an application based on mongo and sails, and i am testing how the realtime update in sails works. I am using sails 0.9.16 now, but i am interested also in answers about sails 0.10. I want a list to be updated when new documents are created in the corresponding collection. This works when i add documents via sails sockets, sending a post message. In that case i see other clients receiving a message and the list on the client side is updated. There is an external service writing

How do I upload a file using node js?

此生再无相见时 提交于 2020-01-06 02:13:05
问题 I have looked around and looked at various tutorials on how to upload a file using node/express. I feel like I am doing something wrong on either the HTML or JQuery side. I am using the following link as a http://howtonode.org/really-simple-file-uploads. However I am getting the error: TypeError: Cannot read property 'fileUpload' of undefined at module.exports.fileCreate Here is my code below: uploadcontroller.js fs.readFile(req.files.fileUpload.path, function (err, data) { var newPath = _

Sails 0.10 req.files empty on file upload

≯℡__Kan透↙ 提交于 2020-01-05 12:14:18
问题 I'm doing a file upload to sails v0.10 via POST /file/upload HTTP/1.1 Host: localhost:1337 Cache-Control: no-cache but the req.files object remains empty in sails upload: function(req,res) { console.log(req.files); // {} } in my file controller. What am I doing wrong? Thanks! 回答1: One should know that since sails v0.10-rc6 the Skipper-middleware is automatically used, so if you're having the same issue, don't use 'req.files' anymore but use the req.file('name') function (https://github.com

Sails 0.10 req.files empty on file upload

血红的双手。 提交于 2020-01-05 12:14:09
问题 I'm doing a file upload to sails v0.10 via POST /file/upload HTTP/1.1 Host: localhost:1337 Cache-Control: no-cache but the req.files object remains empty in sails upload: function(req,res) { console.log(req.files); // {} } in my file controller. What am I doing wrong? Thanks! 回答1: One should know that since sails v0.10-rc6 the Skipper-middleware is automatically used, so if you're having the same issue, don't use 'req.files' anymore but use the req.file('name') function (https://github.com