Django:如何让第 3 方网站访问服务器上的图像。(访问权限有限,即只能访问该文件夹)
我正在 Django 中工作。我正在尝试将我的网站连接到 Facebook。我想做的是
1)发送 post_data
post_data = [('access_token',access_token), ('message', message), ('link', some_link),('picture',internal_server_path_of_image)
2)urllib2.urlopen(graph_url, urllib.urlencode(post_data))
这应该做的是将该数据发布到用户的 Facebook 个人资料上。但我无法访问“internal_server_path_of_image”。无论如何,我可以使我的服务器上的特定文件夹可供该网站使用吗?即该文件夹中的图像应该可以从外部访问。 例如我有文件夹 site_name/project/images/photos.png 在服务器 some_server.dreamhost.com/site_name/project/images/photos.png 上。现在我想以某种方式访问该图像。
问题清楚吗?或者我需要添加一些东西吗? 任何帮助将不胜感激。
I am working in Django.I am trying to connect my website to Facebook. What i want to do is
1)Send post_data
post_data = [('access_token',access_token), ('message', message), ('link', some_link),('picture',internal_server_path_of_image)
2)urllib2.urlopen(graph_url, urllib.urlencode(post_data))
What this should do is post that data on the facebook profile of a user. But i am unable to access "internal_server_path_of_image". Is there anyway in which i can make a particular folder on my server available to the site ? i.e. the images on that folder should be accessible from outside.
for e.g. I have folder site_name/project/images/photos.png
on the server some_server.dreamhost.com/site_name/project/images/photos.png. Now i want to access this image somehow.
Is the question clear ? or do I need to add a few things ?
Any help will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经提出了一个解决方案。正如人们所指出的,图像字段为我们提供了图像的 url。确实如此,我现在所做的就是传递该网址。在那个网址我写了一个控制器方法。该方法只是渲染图像并返回它。这允许访问 facebook api 以从我的服务器获取所需的图像。
希望这对其他人有帮助
I have come with a solution. As people had pointed out that the imagefield gives us the url of the image. That was true, what i am doing now is passing that url. At that url i have written a controller method. This method simply renders the image and returns it. This gives access to the facebook api to get the required image from my server.
Hope this helps others