Create a direct connection between client pc and remote frp server
Good day to everyone..
I'm devoloping an Asp.Net Web Application in which I have to implement file upload, but with a little complication:
To better explain, the application is running on server 开发者_运维问答"A".. the files need to be uploaded to a completely distinct server "B"..
Once the client "C" uploads a file through the site interface, the file must actually be uploaded to server B.
Technically I already achieved this:
- client choses the file he wants to upload from his pc, then click "upload"
- during the postBack of the page", the server upoloads the file without saving it
- I pick up the fileStream from the FileUploas control and send it via ftp to server "B";
BUT, by doing this, actually the file is transferred twice (C -> A -> B), making the user experience of the file upload longer than normal..
My question is: is it possible to open a "direct" connection between "C" and "B" through the site interface (running on server "A"), in order to perform a single transfer? Obviously, I should be able to do the same thing during download..
An alternative (at least during upload) should be that of "hiding" the double transfer by saving a temp file on server "A", and then re-transfer it to "B" starting a separated task, so that the user will be able to perform new actions on the site after the "first" upload.
Any suggestion is greatly appreciated (even quite different solutions, I'll then evaluate the "compatibility" with my project)
Thank you in advance,
Alberto
Note: I choose to go for FTP because the client must be able to select where he want the "B" server to be placed (he can use "our" ftp or, if he has one, send files there) and I think that FTP is the most "compatible" and "fast set up" solution, being ftp managed similarly independently to the server "B" platform.
It's not clear, what kind of connection you expect from C to be capable of making. If C can open direct connection to B, and if the server A has credentials for accessing B, the scenario can look as follows:
- client C establishes command channel with server A
- server A establishes command channel with server B
- the client starts preparation for data transfer. At this point C requests passive mode from server A. A immediately starts preparation for data transfer with server B and requests passive mode from server B. This A-B preparation should take place completely between the server A receives PASV command from C and when it sends response to this command. So it should be quick (2-3 seconds max, I think).
- Server A gets the address and port to connect to from server B and sends this data as a response to PASV command received from C.
- C transfers the data to B. Server A receives "Transfer complete" from B via command channel and sends the same to the client.
- Now server A can close command channel to server B (if needed).
The above requires that you know details of FTP protocol and most likely implement it yourself as both client and server. And this can be quite time-consuming.
精彩评论