Search Results for

    Show / Hide Table of Contents

    Save to FTP server

    In this article, we will consider the method of sending a report to an FTP server. Instructions on how to work with tasks are described in the General information section.

    Getting started

    You will need the following tools and facilities:

    1. Know how to use API key in FastReport Corporate Server.

      This article will skip over additional information on authentication and authorization.

    2. .NET SDK.

    3. C# code editor or text editor, e.g., Visual Studio Code.

    4. Report template.

      It can be generated in the free FastReport Community Designer program.

    5. Active FastReport Corporate Server subscription.

    6. Internet access.

    7. Configured and available FTP server.

    Important! These guides assume that you already know how to develop your application in the C# programming language.

    Note. The items above describe recommended tools.

    Important! This guide assumes that you have experience setting up and configuring an FTP server to receive files from external sources.

    Create task

    Let’s consider creating a task of sending a template to an FTP server and its subsequent launching:

    // Object initialization
     CreateFTPUploadTaskVM ftpUploadTaskVM = new CreateFTPUploadTaskVM
     {
         Name = "Task of sending to FTP",
         InputFile = new InputFileVM
         {
             EntityId = "{template ID}",
             Type = FileKind.Template
         },
         FtpHost = "{FTP server address}",
         FtpPort = 21,
         FtpUsername = "{FTP server user name}", 
         FtpPassword = "{password}",
         UseSFTP = false,
         DestinationFolder = "{/older_path/}",
         Archive = false,
         ArchiveName = "Archive name",
         SubscriptionId = "{workspace ID}"
     };
    
    // Create tasks
     TaskBaseVM ftpUploadTask = await tasksClient.CreateTaskAsync(ftpUploadTaskVM);
    
    // Start a task by ID
     await tasksClient.RunTaskByIdAsync(ftpUploadTask.Id);
    

    Real object IDs should be written to the EntityId and SubscriptionId fields. Otherwise, the task will be terminated with an error.

    Execute task from the request body

    // Start a task from the request body
     await tasksClient.RunTaskAsync(new RunFTPUploadTaskVM
     {
         InputFile = new RunInputFileVM
         {
             EntityId = "{template ID}",
             Type = FileKind.Template
         },
         FtpHost = "{FTP server address}",
         FtpPort = 21,
         FtpUsername = "{FTP server username}",
         FtpPassword = "{password}",
         UseSFTP = false,
         DestinationFolder = "{/folder_path/}",
         Archive = false,
         ArchiveName = "Archived template",
         SubscriptionId = "{workspace ID}"
     });
    

    Important! In this case, this request will send to FTP directly and the task will not be saved in the database.

    Update task by ID

     await tasksClient.UpdateTaskAsync("{old task ID}", new UpdateFTPUploadTaskVM()
     {
         InputFile = new RunInputFileVM
         {
             EntityId = "{updated template ID}",
             Type = FileKind.Template
         },
         FtpHost = "{updated FTP server address}",
         FtpPort = 21,
         FtpUsername = "{updated FTP server username}",
         FtpPassword = "{password}",
         UseSFTP = false,
         DestinationFolder = "/updated_folder_path",
         Archive = false,
         ArchiveName = "updated archive name"
     });
    
    Back to top 2025.2.6 © 1998-2025 Copyright Fast Reports Inc.