2016-07-01 14 views
0

POST時にHerokuのFilebrowser & S3を使用して500エラーを取得しています。私はスタックトレースとモデル情報を追加しました:)これはS3問題かFilebrowserと何か関係がありますか?端末からHeroku + S3のDjango-Filebrowser 500エラー

スタックトレース:

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) 

私もこの1のデバッグを開始するかどうかはわかりません。

[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' 

そして、ここでは、モデルです。誰でもこれについての洞察を持っていますか?どうも!

+0

完全なスタックトレースを表示し、エラーを生成するコードは開始するのに適しています;-)。 – solarissmoke

+0

上記に追加:-) thanks –

+0

「MediaStorage」はどこから来たのですか?設定したストレージバックエンドを表示してください。私は、独自のストレージを定義しています – solarissmoke

答えて

0

がこれを答えることを忘れ...

Filebrowserはジャンゴ・ストレージと互換性がありません。

ありがとうございます@solarissmoke

関連する問題