Transfer large file to golang

Send a client send file, the size of which can be more than 5G, to the slave server, and not the slave, to the main server.

Will slave save the temp file to itself? I do not want this to happen, because it will slow down the download speed and lose working memory.

How to avoid this? And what's the best way to transfer a large file to golang?

+1
source share
1 answer

Yes, there is a standard way to avoid the approach to storage and transition: as soon as the client connects to the slave server, the latter should open a connection to the main server and then simply transfer data from the client. This is usually done using a function io.Copy(). Thanks to the excellent duck printing using interfaces, this works for TCP connections and HTTP requests / responses.

(To get a better explanation, you should narrow down your question.)

Part of the solution even appears in similar questions suggested by stackoverflow here .

+3
source

Source: https://habr.com/ru/post/1537618/


All Articles