agent icon indicating copy to clipboard operation
agent copied to clipboard

Upload fails on big files (>32MB)

Open chiptus opened this issue 6 years ago • 11 comments

When uploading big files, the handler return 404 error with the following message:

{
  "err": "Invalid request payload",
  "details": "Invalid file path"
}

I checked some file sizes and it seems like 32MB is the limit.

chiptus avatar Oct 11 '18 07:10 chiptus

I'm just curious that what you are actually trying upload to there is you need support for that big files?

olljanat avatar Oct 11 '18 07:10 olljanat

Could be related to https://github.com/portainer/libhttp/issues/1

Especially https://github.com/portainer/libhttp/blob/develop/request/request.go#L44

@kendrickm could you investigate?

deviantony avatar Oct 11 '18 20:10 deviantony

Did a quick investigation on this, you can get more details about the issue by replacing the browsePutPayload Validate method with this one:

func (payload *browsePutPayload) Validate(r *http.Request) error {
	file, filename, err := request.RetrieveMultiPartFormFile(r, "file")
	if err != nil {
		return err
		// return agent.Error("Invalid uploaded file")
	}
	payload.File = file
	payload.Filename = filename

	path, err := request.RetrieveMultiPartFormValue(r, "Path", false)
	if err != nil {
		return agent.Error("Invalid file path")
	}
	payload.Path = path

	return nil
}

I was not able to figure out more details about this. Not a priority though, I'd rather see https://github.com/portainer/agent/issues/25 closed first.

deviantony avatar Oct 11 '18 23:10 deviantony

@olljanat just because we give the ability to upload files means that some users will try to upload any kind of files :-)

deviantony avatar Oct 11 '18 23:10 deviantony

Sure but IMO at least on first version it would good enough to give user friendly error message.

Uploading big files is anyway bit tricky as there is many times other components too which user need to take care of. Example on NGINX (which is most common reverse proxy on container world) default upload limit is 1MB.

olljanat avatar Oct 12 '18 04:10 olljanat

Hello, I wonder if this problem is solved or is there a solution? Thank u very much.

vast-z avatar Apr 13 '20 09:04 vast-z

Hi @vast-z we don't have any solution for that issue yet. As it was reported in the comments, some other components (such as reverse proxies) can also limit the request size.

deviantony avatar Apr 13 '20 22:04 deviantony

Thank you very much, can you tell me about the reverse proxy part of the project? I can make some modifications myself to use.

vast-z avatar Apr 14 '20 01:04 vast-z

@vast-z there is no reverse proxy shipped with Portainer. If you are using one (such as haproxy, nginx...) you might need to tune the configuration of the reverse proxy.

If you're not using any (accessing Portainer via IP directly) then this is an issue with the agent that we might need to investigate.

deviantony avatar Apr 14 '20 05:04 deviantony

Thank u very much. Yes, I didn't use a proxy and used ip directly, but the problem I encountered was that a timeout setting in portainer could not upload. I used chrome to slow down the internet speed and then uploaded a small file. After about 7-8 seconds, the connection timeout and turned off. I want to find this timeout setting and I can complete the upload.

vast-z avatar Apr 14 '20 13:04 vast-z

@vast-z We do not know what might be causing this issue at the moment.

See my two previous comments about this:

  • https://github.com/portainer/agent/issues/28#issuecomment-429107782

  • https://github.com/portainer/agent/issues/28#issuecomment-429154065

deviantony avatar Apr 14 '20 23:04 deviantony