Skip to content

request.FILES close #5209

Closed
Closed

Description

@dilyanpalauzov

Django closes transparently the elements of requests.FILES since django/django#2747 , but Django Rest Framework forgets doing so. In particular it leaves /tmp/*.upload files.

Activity

  1. xordoquy commented on Jun 12, 2017

    @xordoquy
    Contributor

    Django REST framework system is built on top of Django's. Moreover, I've seen cases where test failed because the file was closed during the API call.
    I'm closing the issue due to the lack of evidences.
    Will reconsider with a failing test case we can reproduce.

  2. dilyanpalauzov commented on Jun 12, 2017

    @dilyanpalauzov
    Author

    demo.zip

    Here curl -F file=@/tmp/fff http://localhost:8080/A/ does not leave /tmp/.....upload file, but curl -F file=@/tmp/fff http://localhost:8080/Z/ leaves.

    Note FILE_UPLOAD_HANDLERS = ['django.core.files.uploadhandler.TemporaryFileUploadHandler']

  3. rpkilby commented on Jul 6, 2017

    @rpkilby
    Contributor

    Hi @dilyanpalauzov - the demo definitely demonstrates that temporary files remain after the request has been processed by DRF. DRF's stream processing is preempting Django's own data/files handling, so the underlying Django request object doesn't have any _files to close.

    Would you be willing to open a PR with a failing test case?

  4. reopened this on Jul 6, 2017
  5. dilyanpalauzov commented on Jul 6, 2017

    @dilyanpalauzov
    Author

    I do not have the time to delve how to write test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions