开发者

Where to save scraped images?

I'm building a Ruby on Rails app that scrapes the images off a website. What is the best location to save this images to?

Edit: To be clear, I know the file system is the best type of storage, but where on the file system? I suppose I have to stay in the 开发者_开发技巧RoR app directory, but which folder is best suitable for this? public?


On your file server (static Apache server), on your app server (save some where locally in the disk and serve via the app server) or on Amazon S3

But I would suggest not to store in Database. (Some people think it's alright. So, I would be limited to suggestion)


in ROR, under <app_name>/public/images see here -- but the data will be public. If you are worried about privacy, probably this is not right.

If you are concerned about privacy, see the options discussed here How to store private pictures and videos in Ruby on Rails But as a sughestion: serving files from app-server may be painful in high traffic conditions and my experience is it better off-loaded to a file server or a cloud like S3.


It's not hard to write and/or create a server that is only serving images from a file store outside your website's directory structure. A simple rewrite of the URL can provide your code with the info it needs to the actual file location, which it then outputs to the browser.

An alternate is to have the image's URL mapped to the image's directory path in a database, then do a lookup. Make the URL field an indexed lookup and it will be very fast.

I wrote an image server in Ruby a couple years ago along those lines and it was a pretty simple task.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜