Opened 4 years ago

Last modified 4 years ago

#32452 closed New feature

Simplify storing strings/bytes in a Storage — at Version 1

Reported by: Thomas Güttler Owned by: nobody
Component: File uploads/storage Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Thomas Güttler)

Docs: https://docs.djangoproject.com/en/3.1/topics/files/#storage-objects

path = default_storage.save('path/to/file', ContentFile(b'new content'))

Things would be bit easier, if save() would support strings/bytes directly.

This way a developer needs to type and import less code:

path = default_storage.save('path/to/file', b'new content')
path = default_storage.save('path/to/file', 'new unicode string, encoded automatically with utf-8')

Would you accept a patch to Storage.save()?

Change History (1)

comment:1 by Thomas Güttler, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top