Ошибка Django-Filebrowser 500 на Heroku + S3

140
18

Получение ошибки 500 с использованием Filebrowser & S3 на Heroku при POST. Я добавил статистику стека и информацию о модели :) Возможно ли, что это проблема S3 или что-то общее с Filebrowser?

Трассировка стека от терминала:

[01/Jul/2016 05:19:10] "GET /admin/filebrowser/browse/?pop=1&dir=300x250/160x600 HTTP/1.1" 500 76295
Internal Server Error: /admin/filebrowser/browse/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/scott/Sites/banner_preview_tool_venv/banner_preview_tool/filebrowser/decorators.py", line 35, in decorator
if get_path('', site=site) is None:
File "/Users/scott/Sites/banner_preview_tool_venv/banner_preview_tool/filebrowser/decorators.py", line 18, in get_path
if site.storage.isdir(converted_path):
File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 205, in inner
return func(self._wrapped, *args)
AttributeError: 'MediaStorage' object has no attribute 'isdir'
2016-07-01 05:19:14,947 ERROR Internal Server Error: /admin/filebrowser/browse/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/scott/Sites/banner_preview_tool_venv/banner_preview_tool/filebrowser/decorators.py", line 35, in decorator
if get_path('', site=site) is None:
File "/Users/scott/Sites/banner_preview_tool_venv/banner_preview_tool/filebrowser/decorators.py", line 18, in get_path
if site.storage.isdir(converted_path):
File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 205, in inner
return func(self._wrapped, *args)
AttributeError: 'MediaStorage' object has no attribute 'isdir'

И вот модель:

file = FileBrowseField("HTML or ZIP File", max_length=256, blank=True, null=True, extensions=[".zip",".html"], help_text="Upload an html file or a zip file of banners")

def save(self, *args, **kwargs):
self.slug = slugify(self.name)

super(BannerCode, self).save(*args, **kwargs)

def __unicode__(self):
return self.name

def post_upload_callback(sender, **kwargs):
if kwargs['file'].extension == ".zip":
path = kwargs['path']
thefile = kwargs['file']

# Convert file and dir into absolute paths
fullpath = os.path.join(settings.MEDIA_ROOT, '' + thefile.path)
dirname = os.path.dirname(fullpath)

# Get a real Python file handle on the uploaded file
fullpathhandle = open(fullpath, 'r')

# Unzip the file, creating subdirectories as needed
zfobj = zipfile.ZipFile(fullpathhandle)
for name in zfobj.namelist():
if name.endswith('/'):
try: # Don't try to create a directory if exists
os.mkdir(os.path.join(dirname, name))
except:
pass
else:
outfile = open(os.path.join(dirname, name), 'wb')
outfile.write(zfobj.read(name))
outfile.close()

# Now try and delete the uploaded .zip file and the __MACOSX dir if they exist.
try:
os.remove(fullpath)
except:
pass

try:
osxjunk = os.path.join(dirname,'__MACOSX')
shutil.rmtree(osxjunk)
except:
pass

# Signal provided by FileBrowser on every successful upload.
filebrowser_post_upload.connect(post_upload_callback)

Я не уверен, как начать эту отладку. Кто-нибудь знает об этом? Спасибо!

спросил(а) 2021-01-25T09:30:19+03:00 4 месяца, 3 недели назад
1
Решение
78

Забыл ответить на этот вопрос...

Filebrowser не совместим с django-хранилищами.

Спасибо @solarissmoke

ответил(а) 2021-01-25T09:30:19+03:00 4 месяца, 3 недели назад
Ваш ответ
Введите минимум 50 символов
Чтобы , пожалуйста,
Выберите тему жалобы:

Другая проблема