First of all, I need to say: My Linode server recently FTP and SFTP is not connected, the port is blocked, only HTTP can access, I have no way to upload files.
Because I usually use beyond compare upload files, very convenient. So I want to be able to connect to the remote HTTP server by starting an FTP service locally, so that my beyond compare can continue to use.
The requirement is simple, just implement an extensible FTP server, and then rewrite the part of the read file to access the file system on the server through the remote HTTP interface.
After a few days of effort, the function has been fully realized.
Problems encountered:
1. Large files, for large files, the general HTTP server has the upload file size limit, I was uploaded by paragraph, so there will not be this problem. You can upload an issue of any size.
2. The above problem is derived from the new problem, if the file is too large, upload by segment may initiate a lot of HTTP requests, too many connections may run out of the local socket port,
A long connection of http1.1 is currently used to reduce the number of connections and to set the socket reuseaddress to true at the same time.
3. Multipart upload can not be too small, otherwise very slow, if too large, wasting memory, if you upload too many files, it is likely to quickly run out of virtual machine memory, because too late to release.
So adopt the policy of automatically resizing cache, start with a very small cache, each flush cache size will be expanded one time until the configured maximum value, the maximum is not more than 1M (configurable).
The general small file, basically does not need to expand.
4. In order to make the program as simple as possible, the beginning of uploading the use of paragraph data when the use of Base64 encoding, the test of large files feel slower, and later changed to chunked mode upload, speed can be increased several times.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
FTP Bridge to HTTP service