Skip to content

Commit

Permalink
Merge pull request #1237 from hanshuaikang/feature/develop_by_han
Browse files Browse the repository at this point in the history
bugfix: django 3.2.13 版本下文件上传问题修复
  • Loading branch information
hanshuaikang authored Nov 16, 2023
2 parents 7cd3393 + bbf9b4c commit 6390034
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion adapter/utils/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

from django.core.files.storage import Storage
from django.core.files import File


class CephStorage(Storage):
Expand All @@ -35,8 +36,23 @@ class CephStorage(Storage):
def storage(self):
from bkstorages.backends.rgw import RGWBoto3Storage

class CustomRGWBoto3Storage(RGWBoto3Storage):
def save(self, name, content, max_length=None):
"""
去除validate_file_name(name, allow_relative_path=True) 检查,保证content的可用性
"""
if name is None:
name = content.name

if not hasattr(content, "chunks"):
content = File(content, name)

name = self.get_available_name(name, max_length=max_length)
name = self._save(name, content)
return name

if self._storage is None:
self._storage = RGWBoto3Storage()
self._storage = CustomRGWBoto3Storage()

return self._storage

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 请确保指定的包和版本号,可通过pip安装

# blueapps requirement
Django==3.2.4
Django==3.2.13
PyMySQL==0.6.7
mysqlclient==2.0.3
MarkupSafe==1.1.1
Expand Down

0 comments on commit 6390034

Please sign in to comment.