项目作者: h-nasu

项目描述 :
File sharing platform. (nodejs, mongodb, and gridfs)
高级语言: JavaScript
项目地址: git://github.com/h-nasu/shary.git
创建时间: 2015-05-18T08:53:31Z
项目社区:https://github.com/h-nasu/shary

开源协议:

下载


Shary

Shary is an open source file sharing platform created with Sailsjs(Nodejs) and Mongodb, using GridFS for file storing and streaming.

  • Web Server: Nginx
  • Web Programming Language: Nodejs
  • Nodejs Framework: Sailsjs
  • Database: Mongodb
  • Frontend Javascript Framework: Angularjs
  • Frontend Styling: Bootstrap

Live Demo: http://sharydemo-hnasu.rhcloud.com/

username: admin

password: admin135

Set Up

Will Need to install Nodejs and Mongodb in your environment.

Clone or download source code from repository and install all the dependencies.

  1. npm install

Create intial user inside Mongodb (can set up db user as you wish)…

Initial user account can be anything but here is just an example.

  1. use yourDatabase;
  2. db.user.insert(
  3. {
  4. "_id" : ObjectId("54b9f5ce2df9147127007652"),
  5. "username" : "admin",
  6. "password" : "$2a$10$VYm8D8gpt3lVKwtD7VHxL.PkFpWHBpJuISv4gLMRAFffp/mZ1YmlW",
  7. "email" : "admin@admin.com",
  8. "admin" : true,
  9. "spaceLimit" : 2,
  10. "totalUsage" : 0,
  11. "user_id" : "54b9f5ce2df9147127007652"
  12. }
  13. );
  14. // This will create...
  15. {
  16. username: 'admin',
  17. password: 'admin'
  18. }

Below is just an example of creating user for mongodb.

  1. db.createUser(
  2. {
  3. user: "username",
  4. pwd: "password",
  5. roles: [{role:"readWrite", db:"database"}]
  6. }
  7. );

Below are some settings you can change depending on your environment.

  1. // config/connections.js
  2. // mongodb config
  3. someMongodbServer: {
  4. adapter: 'sails-mongo',
  5. host: 'localhost',
  6. port: 27017,
  7. user: '',
  8. password: '',
  9. database: ''
  10. },
  11. // config/session.js
  12. // use mongodb config for session storage
  13. adapter: 'mongo',
  14. host: 'localhost',
  15. port: 27017,
  16. db: '',
  17. collection: 'sessions',
  18. username: '',
  19. password: '',
  20. auto_reconnect: true,
  21. // config/local.js
  22. // If need, running port can be changed from config/local.js.
  23. port: some_port#
  24. // confog/models.js
  25. // When running the application for first time, please set the migration mode to 2 (alter).
  26. // 2(alter) will create needed collections in mongodb for running the sails application.
  27. // And change the migration to safe after...
  28. migrate: 'safe'

If you using Nginx or Apache for proxy, max body limit for upload file need to be set.

  1. # This is an example setting for Nginx
  2. # /etc/nginx/nginx.conf
  3. http {
  4. ...
  5. # Set the max body size limit
  6. # 1M -> 1 megabyte
  7. # 0 -> do not set the limit
  8. client_max_body_size 0;
  9. ...
  10. }

Start the application from terminal.

  1. cd shary
  2. sails lift

You can use foreverjs and nodemon to keep the application running.

Make sure you create .foreverignore in the root directory.

  1. cd shary
  2. vi .foreverignore
  3. # insert below to .foreverignore
  4. **/.tmp/**
  5. # stop the application and re-run it with below command
  6. forever -w -c nodemon app.js --exitcrash

You can access your site with…

http://localhost:port/