1

I am trying to use nginx for serving static contents(images/css etc.) I need to span up multiple instances of nginx to support as per the incoming load. So i am looking for Mongo+gridfs solution to store the static files- since it provides replication and sharding. I see i can serve contents from gridfs using either of these these modules. Direct nginx module - https://github.com/mdirolf/nginx-gridfs

Using Lua scripting language https://github.com/bigplum/lua-resty-mongol

Question is - can i create UploadImage api in nginx itself to store files in gridfs when user calls a POST method passing the file.

It looks to me that it is possible using lua resty module but not sure. Any idea?

Sumant Das
  • 19
  • 6

2 Answers2

0

You can use the lua-resty-upload module to handle user uploads, and then pass the data over to lua-resty-mongol for writing to Mongo.

For large files you may be able to write the chunks directly as they are read to avoid buffering all of the data in memory, there's a good example on the page using a file.

Chris Tanner
  • 1,624
  • 1
  • 12
  • 20
  • Thanks. I am trying to use the lua-resty-mongol module.. but over there its written gridfs is under development? I am trying it now. but can you tell if you have used this module for gridf or not? – Sumant Das Aug 22 '16 at 14:55
  • Also i see this module https://github.com/moai/luamongo . Instead of resty mongol can this be used – Sumant Das Aug 22 '16 at 16:54
0

I have used the upload resty module along with lua mongol module.. and it works well.. Now i got a suggestion from people around to see if we can use java. instead of lua to do db connections primarily to store retrive static file contents.

I see there is a Java module as well that can be used to do the job, or can use php or python as well in nginx.

Q is What would be the difference in using any of these languages- Lua vs Java vs PHP. and what factors should i need to consider while picking up a language.. Performance, solution usage, packaging, etc. Point of view

Sumant Das
  • 19
  • 6