Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: expected str, bytes or os.PathLike object, not ImageFieldFile with Dropbox backend #713

Closed
math-a3k opened this issue Jun 5, 2019 · 0 comments · Fixed by #724

Comments

@math-a3k
Copy link
Contributor

math-a3k commented Jun 5, 2019

Using:

Django==2.2.1
django-storages==1.7.1
dropbox==9.3.0
wagtail==2.5.1

After uploading an image, a TypeError is raised (traceback follows). The image gets uploaded to Dropbox, so the problem seems to be when it comes to retrieve the info of the file from Django. The S3 backend works with the same stack, so I guess this is specific to the Dropbox backend.

Internal Server Error: /admin/images/multiple/add/
Traceback (most recent call last):
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/wagtail/admin/urls/__init__.py", line 102, in wrapper
    return view_func(request, *args, **kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/wagtail/admin/decorators.py", line 34, in decorated_view
    return view_func(request, *args, **kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/wagtail/admin/utils.py", line 151, in wrapped_view_func
    return view_func(request, *args, **kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/views/decorators/vary.py", line 20, in inner_func
    response = func(*args, **kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/wagtail/images/views/multiple.py", line 74, in add
    image.save()
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/base.py", line 741, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/base.py", line 779, in save_base
    force_update, using, update_fields,
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/base.py", line 870, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/base.py", line 908, in _do_insert
    using=using, raw=raw)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/query.py", line 1186, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1334, in execute_sql
    for sql, params in self.as_sql():
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1278, in as_sql
    for obj in self.query.objs
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1278, in <listcomp>
    for obj in self.query.objs
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1277, in <listcomp>
    [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1228, in pre_save_val
    return field.pre_save(obj, add=True)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/fields/files.py", line 288, in pre_save
    file.save(file.name, file.file, save=False)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/fields/files.py", line 88, in save
    setattr(self.instance, self.field.name, self.name)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/fields/files.py", line 346, in __set__
    self.field.update_dimension_fields(instance, force=True)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/db/models/fields/files.py", line 449, in update_dimension_fields
    width = file.width
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/core/files/images.py", line 19, in width
    return self._get_image_dimensions()[0]
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/core/files/images.py", line 29, in _get_image_dimensions
    self._dimensions_cache = get_image_dimensions(self, close=close)
  File "/home/bot/code/conuruinca/venv/lib/python3.7/site-packages/django/core/files/images.py", line 47, in get_image_dimensions
    file = open(file_or_path, 'rb')
TypeError: expected str, bytes or os.PathLike object, not ImageFieldFile

@math-a3k math-a3k changed the title TypeError: expected str, bytes or os.PathLike object, not ImageFieldFile with Dropbox backend on TypeError: expected str, bytes or os.PathLike object, not ImageFieldFile with Dropbox backend Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant