question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A question about uploading files to an FTP server using FluentFTP

See original GitHub issue

First of all, thank you for making tusdotnet project to provide dotnet developers with the ability of using Tus.

I am using tusdotnet in my asp.net core 3.1 project with uppy and react and I have a question about uploading files to an FTP server with FluentFTP.

I can connect to my FTP server through FluentFTP and upload files like this:

using FluentFTP;

// creating FTP client
FtpClient client = new FtpClient(_baseUri, _port, _username, _password);
// Connecting to the FTP server
await client.ConnectAsync();

using (var stream = file.OpenReadStream())
{
     ...
     // Uploading file to the FTP server
     var ftpStatus = await client.UploadAsync(stream, fileRelativePath);

   ...

}

 // disconnect!
await client.DisconnectAsync();

I have read some articles in wiki of tusdotnet repo about its interfaces. If I should change any implementation please explain which methods need to be changed in new implementation and how could I make tusdotnet to use new implementation instead of its default implementation.

The question is, how can I use tusdotnet in a way that I can upload files directly to the FTP server using FluentFTP?

Thank you in advance…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jkoplocommented, Nov 19, 2020

I’m actually doing something similar - in my case using tus as an upload protocol for embedded controllers on an Edge server and then FTPing received files to a final destination on a different server. I hadn’t considered creating an FTP backend for tusdotnet, but I don’t think I’d want to. In my scenario it’s better to collect files on the edge server if the network is down.

My strategy is this:

  1. On receiving a file (OnFileCompleteAsync) I add the fileid to an SQLite database that keeps track of files to be transferred to FTP.
  2. I have a background worker service that periodically queries the SQLite database to see if there are any files that need to be transferred.
  3. I use FluentFTP to execute a transfer process. In my case this involves uploading, downloading, checking that the files match and then deleting the file from the TusDiskStore and removing it from my SQLite database.

That may or may not suit your needs, but I’ve had good success with it thus far in dev.

1reaction
smatssoncommented, Nov 2, 2020

Hi!

What you are looking for is a custom store so start by reading this article: https://github.com/tusdotnet/tusdotnet/wiki/Custom-data-store

The interfaces that your store need to implement depends on what extensions from the tus protocol you need as each interface represent an extension.

As a baseline you need to implement ITusStore to have support for the core protocol and probably also ITusCreationStore to be able to create new files.

Then pass your own store to the setup of tusdotnet:

app.UseTus(httpContext => new DefaultTusConfiguration
{
    Store = new YourCustomStore(), // <-- replace with an instance of your store
    UrlPath = "/files"
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stream file from FTP server using FluentFTP to web client ...
1 Answer 1 ... Download the file directly to the HTTP output stream with use of FtpClient.DownloadStream ( FtpClient.Download in older versions) ...
Read more >
UploadDirectory fails for some files stating "File failed to ...
When I upload a directory to a production server some files fail. ... So I don't think it's a problem with the files....
Read more >
Newest 'fluentftp' Questions
I'm uploading files using FluentFTP Nuget package (UploadFile()). The ftp server is set up so that any added directories/files should ...
Read more >
How do I send selected textfiles to an ftp server
Connect(); If there's a better way to send the files to the ftp server I'm ok with it. I'm using FluentFTP.
Read more >
Upload file to ftps server using time trigger Azure Function ...
I'm trying to create a timer trigger Azure Function to upload a file to FTPS location. The below code works fine in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found