#32718: [3.2.1] Issue with assigning file to FileField
-------------------------------------+-------------------------------------
Reporter: Jakub Kleň | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: 3.2.1 file model | Triage Stage: Accepted
filefield fieldfile |
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Florian Apolloner):
Replying to [comment:4 Phillip Marshall]:
> Hi, I came across this as well. I had to make changes like this one all
over my project to get things to work after the CV in 2.2.21.
>
> {{{
> merged_path = '/tmp/merged.png'
> with open(img_path, mode='rb') as f:
> - field.merged_map = ImageFile(f)
> + field.merged_map = ImageFile(f,
name=os.path.basename(merged_path))
> field.save() # raises SuspiciousFileOperation("File name
'/tmp/merged.png' includes path elements") unless change is made on
previous line
> }}}
Hi Phillip, I have tried your original code (without the basename) on 3.2
& 2.2.20 and it yielded this for me:
> SuspiciousFileOperation: The joined path (/tmp/merged.png) is located
outside of the base path component
(/home/florian/sources/django.git/testing)
This was my code (functionally equal to yours):
{{{
In [1]: from django.core.files import File
In [2]: from testabc.models import *
In [3]: f = open('/tmp/merged.png')
In [4]: f2 = File(f)
In [5]: x = Test()
In [6]: x.file = f2
In [7]: x.save()
}}}
So your code already fails for me before any changes. Can you please
provide a reproducer and full traceback?
--
Ticket URL: <https://code.djangoproject.com/ticket/32718#comment:13>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.98a1e71718aa9e9f574bed5b5af87c08%40djangoproject.com.