FTP Server Storage
Products: FastReport Cloud, FastReport Corporate Server, FastReport Publisher
This article covers how to send 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 capabilities:
Knowledge of using API key in Service solutions.
This article will skip additional information on authentication and authorization.
curl tool.
Any other REST client will work, but examples will be built for curl.
Active subscription to one of the following products: FastReport Cloud, FastReport Corporate Server, or FastReport Publisher.
Internet access.
Configured and accessible FTP server.
Note! The points above describe recommended tools.
Note! This guide assumes you have a configured FTP server to accept files from external sources.
Creating a Task
Let's look at creating a template sending task to FTP server:
// Creating a task
curl -X 'POST' \
'https://{host_name}/api/tasks/v1/Tasks' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"$t": "CreateFTPUploadTaskVM",
"name": "FTP sending task",
"subscriptionId": "23e0134c816935c1e11b3737",
"ftpHost": "ftp://localhost",
"ftpPort": 21,
"ftpUsername": "FtpUser",
"ftpPassword": "password",
"archive": false,
"archiveName": "Archive name",
"useSFTP": false,
"inputFile": {
"entityId": "61e0134c816935c1e11b3787",
"type": "Template"
},
"destinationFolder": "/destination_path/"
}'
// Running task by identifier
curl -X 'POST' \
'https://{host_name}/api/tasks/v1/Tasks/{task identifier}/run' \
-H 'accept: */*' \
-d ''
In the EntityId and SubscriptionId fields, you should enter real object identifiers. Otherwise, the task will be terminated with an error.
Executing Task from Request Body
curl -X 'POST' \
'https://{host_name}/api/tasks/v1/Tasks/run' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"$t": "RunFTPUploadTaskVM",
"name": "FTP sending task",
"subscriptionId": "23e0134c816935c1e11b3737",
"ftpHost": "ftp://localhost",
"ftpPort": 21,
"ftpUsername": "FtpUser",
"ftpPassword": "password",
"archive": false,
"archiveName": "Archive name",
"useSFTP": false,
"inputFile": {
"entityId": "61e0134c816935c1e11b3787",
"type": "Template"
},
"destinationFolder": "/destination_path/"
}'
Note! In this case, sending to FTP will be performed directly by this request and the task will not be saved in the database.
Note! The examples don't have the Authorization header because an authentication model based on cookies is used. For more details about authorization, read the section Authentication and Authorization