fetching image from external location in meteor
I am building a meteor app, that allows user to upload images. The images upload are stored in "/tmp/images/" directory in my local system.
How can I display the images from the above directory. So far, I have seen displaying images only from "public" directory in meteor. But if I start adding images uploaded by the user in "public", then everytime the user uploads the image, the server will get refreshed.
So I would basically want to display images from "/tmp/images/" rather.
Any idea?
There is no other way to fetch images from another directories outside the project folder. That is the reason Meteor has built "public" directory for us. The path "/" itself indicates the beginning of project folder. Well if you are storing images in locations like amazon s3, then simply hitting the url in the tag fetch the image.
So the bottom line is either u put ur images in public folder or store images in some outside location which can be fetched by simply hitting the image url.
And don't worry about refresh, it does not happen so in production mode. This only happens in development mode.
You should also look at CollectionFS. This will let you use different storage adapters as your needs evolve without changing your code. It's a very well done and robust package.
I would advise you to store your images using gridFS:
The only place designed in meteor to store static assets is the public
folder. You shouldn't try to put these elsewhere.
If you want to give a try to gridFS, you can use the file-collection package. It is quick and easy to setup.
Alternatively, as advised by @Marius Darila, you can use Nginx to serve static content
As answered by @Michel Floyd, you can also use collectionFS, but, to quote the file-collection package author:
Here's the difference in a nutshell: collectionFS is a Ferrari, and file-collection is a Fiat.
They do approximately the same thing using some of the same technologies, but reflect different design priorities. file-collection is much simpler and somewhat less flexible; but if it meets your needs you'll find it has a lot fewer moving parts and may be significantly more efficient to work with and use.
链接地址: http://www.djcxy.com/p/73414.html上一篇: 何时发生
下一篇: 从流星的外部位置获取图像