Skip to content

Large file uploads to API failing with FileNotFoundError #499

@NiViggiano

Description

@NiViggiano

Querying the API (e.g. /api/validate/) with a file larger than (I believe) 2.5 MB results in an error similar to [Errno 2] No such file or directory: '/tmp/tmpz4g1gbzc.upload.json' in the [Function]FileUpload.objects.create() model calls.

I believe this has to do with Django storing sufficiently large files in a temp location, unlike small files which are stored in memory. It appears that these files are opened twice in most of the API routes, but have already been deleted by the second open. I have fixed this on my local instance by, in the helpers like license_validate_helper in /app/core.py, returning the permanently saved filename as part of the response. Then in the API routes like validate in /api/views.py, the query object is created using file=response['filename'] rather than trying to get the file again from request.FILES['file'].

If you agree with the issue and solution and would like me to send a PR then I will, I was just unsure about your stylistic best practices and if I was the only one experiencing this.

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