Skip to content

Binder: Multipart io.Reader parameters needs to be closed. #756

@klauspost

Description

@klauspost

I have tracked down an issue with revel, where temporary files are leaked.

I have a controller function like this:

func (c File) Replace(id string, file io.Reader, metadata string) revel.Result {

Short story is, if I upload a file larger than 32MB, I get this error:
params.go:121: Error removing temporary files: remove c:\temp\win\multipart-265323653: The process cannot access the file, since it is in use by another process.

The reason for this is, that the file is larger than 32MB, so "req.ParseMultipartForm" in "params.go" places the file on disk. Very reasonable.

However, this also means the "io.Reader" must be closed for the system to be able to delete the file after processing it. This is not done.

So whenever Revel binds a parameter, it should check if it implements io.Closer and call it once the controller has been called.

The workarounds are:

  • Test if the supplied reader is io.Closer in the controller (this should be handled by Revel)
  • Use "os.File" for the controller. Silly, since that would copy it to disk every time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy