Upload a file to a remote server, how should I?

I scratch my head about it. My scenario is that I need to upload a file to the company server (in the folder on c :) from our hosting (a completely different server). I do not know how I should do this. Any of you have tips or code on how to do this.

Thanks guys

+4
source share
3 answers

I would install an FTP server (for example, the one that was in IIS or a third-party server) on the company server. If there is a security problem, then you will want to configure SFTP (secure FTP) rather than vanilla FTP, since FTP is not an inherently secure transfer protocol. Then create a service on the hosting server to receive the file as they arrive and send them to the company server using C # /. NET FTP management. Honestly, this should be pretty simple.

Update:. After reading your question, I have the strong impression that you will NOT have a website running on the company's server. That is, you don’t need the file upload control in your web application (or you already know how to implement the one defined in the web page toolbar). Your question, as I understand it, is how to get a file from a web server to a company server.

Update 2: Added security note. Please note that this is less of a concern if the servers are in the same subdomain and will not be redirected outside the company network and / or if the data is not sensitive. At first I did not think about it, because now I am working on such a project, but our data are in no way sensitive.

+3
source

Controlling file uploads Darren Johnstone is the solution you can find anywhere. It has the ability to process large files without affecting the memory of the ASP.NET server, and can display file download progress without requiring a dependency on Flash or Silverlight.

http://darrenjohnstone.net/2008/07/15/aspnet-file-upload-module-version-2-beta-1/

0
source

There is not enough information to tell your whole hosting scenario, but I have a few tips to help you get started in the right direction:

  • Does your external server belong to another company or group and you cannot change it? If not, you might consider placing the process on the same computer, both in the process and as a separate service on the machine. If the parameter cannot be changed, you can consider placing the service on the destination machine, thereby in the same place where the files should be displayed.
  • Do I need files to synchronize with the process? That is, do they need to be loaded, moved and checked as a single operation? If not, then probably the best way is a separate process. A separate process will give you some flexibility, but remember that it will be a separate process and a separate set of code for managing and working with
  • How large is the file (s) that is being uploaded? Do they change at boot time? simple files, binary files (zip files, executables, etc.)? If the files are small, you have more options than with large ones. If they are small enough, you can even queue them.

Depending on the answers to above, some of these may work for you:

  • Use MSMQ . This will work for simple messages within about 3 MB without the hassle. It is ideal for messages that you can work directly with (for example, XML).
  • Use direct HTTP transmission. On the host machine, open an HTTP connection to the destination computer and transfer the file. Again, this will work better for small files (i.e. just a few KB, as this will be done online).
  • If you have access to the host machine, deploy a separate process on the machine that collects or collects the files and uses any of these methods to send them to the destination computer.
  • You can use SCP, FTP (any form of SFTP, etc.) on the host machine (if you have access) or on the target machine to host incoming files and use the batch process to move files. This will have many problems for solving such problems as file size, synchronization and synchronization. I would consider this as a last resort, depending on the situation.
  • Again, depending on the size of the message, you can also use an abstraction layer, such as a database, to act as an intermediate layer between two machines. This will work as long as two machines can see the database (or another storage location) and both act on it. SQL Server Service Broker can be used for this purpose (and most other DB products offer similar products).
  • You can look at other products, such as WSO2 ESB or NServiceBus , to facilitate messaging between the two applications and do it inline.

Hope this gives you some starting points to explore.

0
source

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


All Articles