Django: sorl-thumbnail and hosting image files on my own file server

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:21:02

问题


I like very much sorl-thumbnail library and I want to store image files not in current application (django) server, but to (another) my own file server with webserver for serving static files.

  • Do I have to write custom django storage or not?
  • How can I upload files to remote static file server(s)?
  • What if I have many application (django) servers and many file servers?
  • Is it better to use custom file upload handler? And if not then when is it useful? And if yes then how to use it with sorl-thumbnail?

P.S. I'm not sure what is the right (good) way to do this, because I have not much experience in web programming and Django.


回答1:


Hmm, perhaps I am not answering the question you meant to ask (don't know anything about sorl-thumbnail), but my first instinct is to cut django out of the picture. If you have some separate server which can serve the files up statically, then just deploy that server. Sure your django application will generate links to those images, but as long as you are clear about your URLs, that should be no problem. You can take this approach even with one web server, configure it to pass only some URLs to django, but handle the image URLs directly.

None of this addresses the uploads issue though...




回答2:


I think the answer to this Django: how to serve user-submitted images & thumbnails from separate, multiple servers? question fits your idea.

Because otherwise you can't just upload the file simply to remote machine. Or you will develope your script to upload files to another host by using scp or something like this...

Cheers, Ignas



来源:https://stackoverflow.com/questions/5674931/django-sorl-thumbnail-and-hosting-image-files-on-my-own-file-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!