django-storages: I can't upload image with dropbox SuspiciousFileOperation
settings.py
STATICFILES_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
DROPBOX_OAUTH2_TOKEN = 'xxx-xxx'
DROPBOX_ROOT_PATH = '/TKYK/'
my models.py
def get_image_filename(instance, filename):
fpath = pathlib.Path(filename)
new_fname = str(uuid.uuid1()) # uuid1 -> uuid + timestamps
return f"patient/{new_fname}{fpath.suffix}"
class Image (models.Model):
me = models.ForeignKey(me, on_delete=models.CASCADE)
images_data = models.FileField(upload_to=get_image_filename)
error when upload via django admin site
But I see the image already uploaded to dropbox
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 15 (3 by maintainers)
Links to this issue
Commits related to this issue
- [dropbox] fix saving files (#1168) Resolves #1109. — committed to jschneier/django-storages by jschneier 2 years ago
I needed to get around this, so FWIW, here is a monkey patch to django that seems to work (not sure if this has any unintended consequences):
I am having the same issue I am using django-dbbackup to send files to dropbox. Django=3.2.11
django.core.exceptions.SuspiciousFileOperation: Detected path traversal attempt in '/default-ubuntu-2022-02-10-114225.psql'