startFileTransfer method

Future<StartFileTransferResponse> startFileTransfer({
  1. required String connectorId,
  2. List<CustomHttpHeader>? customHttpHeaders,
  3. String? localDirectoryPath,
  4. String? remoteDirectoryPath,
  5. List<String>? retrieveFilePaths,
  6. List<String>? sendFilePaths,
})

Begins a file transfer between local Amazon Web Services storage and a remote AS2 or SFTP server.

  • For an AS2 connector, you specify the ConnectorId and one or more SendFilePaths to identify the files you want to transfer.
  • For an SFTP connector, the file transfer can be either outbound or inbound. In both cases, you specify the ConnectorId. Depending on the direction of the transfer, you also specify the following items:
    • If you are transferring file from a partner's SFTP server to Amazon Web Services storage, you specify one or more RetrieveFilePaths to identify the files you want to transfer, and a LocalDirectoryPath to specify the destination folder.
    • If you are transferring file to a partner's SFTP server from Amazon Web Services storage, you specify one or more SendFilePaths to identify the files you want to transfer, and a RemoteDirectoryPath to specify the destination folder.

May throw InternalServiceError. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException.

Parameter connectorId : The unique identifier for the connector.

Parameter customHttpHeaders : An array of key-value pairs that represent custom HTTP headers to include in AS2 messages. These headers are added to the AS2 message when sending files to your trading partner.

Parameter localDirectoryPath : For an inbound transfer, the LocaDirectoryPath specifies the destination for one or more files that are transferred from the partner's SFTP server.

Parameter remoteDirectoryPath : For an outbound transfer, the RemoteDirectoryPath specifies the destination for one or more files that are transferred to the partner's SFTP server. If you don't specify a RemoteDirectoryPath, the destination for transferred files is the SFTP user's home directory.

Parameter retrieveFilePaths : One or more source paths for the partner's SFTP server. Each string represents a source file path for one inbound file transfer.

Parameter sendFilePaths : One or more source paths for the Amazon S3 storage. Each string represents a source file path for one outbound file transfer. For example, amzn-s3-demo-bucket/myfile.txt .

Implementation

Future<StartFileTransferResponse> startFileTransfer({
  required String connectorId,
  List<CustomHttpHeader>? customHttpHeaders,
  String? localDirectoryPath,
  String? remoteDirectoryPath,
  List<String>? retrieveFilePaths,
  List<String>? sendFilePaths,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'TransferService.StartFileTransfer'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ConnectorId': connectorId,
      if (customHttpHeaders != null) 'CustomHttpHeaders': customHttpHeaders,
      if (localDirectoryPath != null)
        'LocalDirectoryPath': localDirectoryPath,
      if (remoteDirectoryPath != null)
        'RemoteDirectoryPath': remoteDirectoryPath,
      if (retrieveFilePaths != null) 'RetrieveFilePaths': retrieveFilePaths,
      if (sendFilePaths != null) 'SendFilePaths': sendFilePaths,
    },
  );

  return StartFileTransferResponse.fromJson(jsonResponse.body);
}