<img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade"/>
taskstemplates
feedback & roadmap30-day trialbook a demo

Frends.FTP.UploadFiles / 1.3.0

Source code
Frends 5.1+Legacy, Crossplatformnet471, net6.0, netstandard2.0

Upload files to an FTP server.

Transfer overview

The file transfer progress has the following steps:

  1. Initialize

    Initializes the transfer and opens the source connection.

  2. ListFiles

    Get a list of files from the source endpoint according to the filename/mask. If there are no files to transfer, the source connections are closed, and the transfer finishes. The result of the task will then depend on what the option NoSourceAction was set to. If it was set to Error, either the #result.Success property will be set to false, or if the `ThrowError

  3. Transfer files If there are files to transfer, they are then transferred individually. For every file in the list returned from the source endpoint, the following process is repeated:

    1. GetFile

      Get a file from the source endpoint to the local work directory. If the parameter RenameSourceFileBeforeTransfer is set to true, the file is first renamed with a temporary filename before transfer.

    2. Rename or move the source file.

      This is done before transferring the file to the destination, this means that possible errors in the renaming or moving that would cause the transfer to fail will happen as early as possible - before we actually try to transfer files onward.

    3. Transfer the file.

      If destination file already exists, depending on the parameter DestinationFileExistsAction either an exception is thrown, the destination file is overwritten or the source file is appended to the destination file. If the parameter RenameDestinationFileDuringTransfer is true, the file is first transferred with a temporary file name and afterwards renamed to intended filename, otherwise the file is transferred with the intended filename. The intended filename has its possible file masks expanded.

    4. Do the source file operation.

      Perform the operation defined by the SourceOperation.

  4. Finish

    Close the source and destination endpoint connections. If the transfer is cancelled (e.g. by calling Terminate on the process instance), the files that are currently being transferred will be processed until finished, but no new files will be transferred. The cancelled transfer end result will be Failed.

Macro reference

Macros can be used to dynamically configure source directory, destination directory or destination file name for a file transfer.

Generally the following rules apply for macros:

  • Macros are case insensitive.
  • You can use any number of macros in all of the cases.
  • Dates and times are formatted with leading zeros.

The following macros can be used with all of dynamically configurable locations for file transfer:

  • %Ticks% = will be replace with the current time as Ticks.
  • %DateTime% = will be replaced with date and time in format: "yyyy-MM-dd-HH-mm-ss".
  • %DateTimeMs% = will be replace with date and time in format: "yyyy-MM-dd-HH-mm-ss-fff".
  • %Date% = will be replaced with date in format: "yyyy-MM-dd".
  • %Time% = will be replaced with time in format: "HH-mm-ss".
  • %Year% = will be replaced with current year.
  • %Month% = will be replaced with current month.
  • %Day% = will be replaced with current day.
  • %Hour% = will be replaced with current hour.
  • %Minute% = will be replaced with current minute.
  • %Second% = will be replaced with current second.
  • %Millisecond% = will be replaced with current millisecond.
  • %WeekDay% = will be replaced with a number of weekday, ranging from 1 (monday) to 7 (sunday).
  • %Guid% = will be replaced with a new unique identifier.
  • %TransferId% = will be replaced with the transfer id.
  • %TransferName% = will be replaced with TransferName parameter specified in Connection point schema.
  • %TransferGroupName% = will be replaced with TransferGroupName parameter specified in routine's task arguments.

Destination file name has two additional macros that can be used for dynamically creating destination file name.

  • %SourceFileName% = will be replaced with source file name without extension.
  • %SourceFileExtension% = will be replaced with source file's extension, with the dot '.' included, i.e. if the source file is named 'foo.txt', the %SourceFileExtension% will be expanded as '.txt'. If the source file name does not have an extension, the macro result will be empty, i.e. for original file name "foo", "bar%SourceFileExtension%" will result in "bar"