Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewind file before saving #91

Merged
merged 2 commits into from
Dec 15, 2017
Merged

Conversation

KostyaEsmukov
Copy link
Contributor

This fixes uploading files which position (seek/tell) is not at the beginning. W/o this uploading files with DRF doesn't work.

Though Django states in the doc that file should be at the beginning before saving:

https://github.com/django/django/blob/42847327d1277451ee7a61716f7b9f62f50ecbdc/django/core/files/storage.py#L42-L44

... practically it doesn't matter, because their own FileStorage implicitly rewinds the file automatically:

https://github.com/django/django/blob/42847327d1277451ee7a61716f7b9f62f50ecbdc/django/core/files/storage.py#L351

https://github.com/django/django/blob/42847327d1277451ee7a61716f7b9f62f50ecbdc/django/core/files/base.py#L76

This patch mimics that behaviour and fixes uploading files with DRF.

@dennisv dennisv merged commit 7a3f924 into dennisv:master Dec 15, 2017
@KostyaEsmukov KostyaEsmukov deleted the pr/rewind branch January 21, 2018 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants