Opened 4 years ago
Last modified 4 years ago
#32452 closed New feature
Simplify storing strings/bytes in a Storage — at Initial Version
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
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()
?