【发布时间】:2016-06-19 14:29:31
【问题描述】:
在我的 Django 应用程序的 models.py 中,我编写了一个名为 OverwriteStorage 的自定义 Storage 类。它的目的是从我使用的第 3 方存储桶(Azure)上传和获取静态对象。
除此之外,此自定义存储类定义了一个名为 url 的方法,其中:
def url(self, name):
"""
Returns the URL where the contents of the file referenced by name can
be accessed.
"""
url = '%s/%s/%s' % ('http://example.blob.core.windows.net','mypictures', name)
return url
此方法实质上返回上传到 Azure 存储 blob 上的静态对象的位置。
我的问题是,有没有办法访问访问存储类的用户的 http-protocol 方案?我的 Django Web 应用程序接受 http 和 https 协议,我想将相关协议附加到此方法返回的 url。
【问题讨论】:
标签: python django python-2.7 django-models