feed mail: use FileContent to avoid SuspiciousOperation (#59894)
This commit is contained in:
parent
f934f78403
commit
2a287e61b9
|
@ -17,7 +17,7 @@
|
|||
import os
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.files import File
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from ...models import Mail
|
||||
|
@ -35,7 +35,7 @@ class Command(BaseCommand):
|
|||
continue
|
||||
if not open(filepath).read(5) == '%PDF-':
|
||||
continue
|
||||
mail = Mail(content=File(open(filepath)))
|
||||
mail = Mail(content=ContentFile(open(filepath).read(), name=os.path.basename(filepath)))
|
||||
mail.scanner_category = kwargs.get('category')
|
||||
mail.save()
|
||||
count += 1
|
||||
|
|
Loading…
Reference in New Issue