aliyun / django-oss-storage

Django storage backends for AliCloud OSS.
MIT License
145 stars 67 forks source link

TypeError: url() missing 1 required positional argument: 'expire' #9

Closed xingfukun closed 4 years ago

xingfukun commented 6 years ago

请问这个怎么解决

VivianSnow commented 6 years ago

手动给expire加上默认值

wonderbeyond commented 6 years ago

什么情况了? 项目要尽快安排人维护啊,毕竟背后是商业产品!

sunsiyuan commented 5 years ago

2.1里没有这个参数了 https://docs.djangoproject.com/en/2.1/ref/files/storage/#django.core.files.storage.Storage.url

sunsiyuan commented 5 years ago

https://github.com/aliyun/aliyun-oss-python-sdk/blob/df1e8fa3b1f6ab50745e5cfdc8bdbc3baba88f5f/oss2/api.py#L352

根据这个来看,在sign_url里随便加个自己觉得合适的expires值就可以了

Shellbye commented 5 years ago

最粗暴、简单又快捷的方法就是把源码拷贝下来,然后在setting.py里面

DEFAULT_FILE_STORAGE = 'django-oss-storage.backends.OssMediaStorage'

然后在backends.py里面,把以下内容

    def url(self, name, expire):
        key = self._get_key_name(name)
        return self.bucket.sign_url('GET', key, expire)

改成

    def url(self, name, expire=9999999999):
        key = self._get_key_name(name)
        return self.bucket.sign_url('GET', key, expire)
huiguangjun commented 4 years ago

fixed in version 1.1.1