@aws-sdk/client-transfer
Description
AWS SDK for JavaScript Transfer Client for Node.js, Browser and React Native.
Transfer Family offers fully managed support for the transfer of files over SFTP, AS2, FTPS, FTP, and web browser-based transfers directly into and out of Amazon Web Services storage services.
File transfer protocols are used in data exchange workflows across different industries such as financial services, healthcare, advertising, and retail, among others. Transfer Family simplifies the migration of file transfer workflows to Amazon Web Services.
To use the Transfer Family service, you instantiate a server in the Amazon Web Services Region of your choice. You can create the server, list available servers, and update and delete servers. The server is the entity that requests file operations from Transfer Family. Servers have a number of important properties. The server is a named instance as identified by a system assigned ServerId identifier. You can optionally assign a hostname, or even a custom hostname to a server. The service bills for any instantiated servers (even ones OFFLINE), and for the amount of data transferred.
Users must be known to the server that requests file operations. A user as identified by their username is assigned to a server. Usernames are used to authenticate requests. A server can have only one authentication method: AWS_DIRECTORY_SERVICE, SERVICE_MANAGED, AWS_LAMBDA, or API_GATEWAY.
Transfer Family also supports web applications that provide browser-based file transfer capabilities. Web applications can be configured with VPC endpoints to enable secure, private connectivity within your Virtual Private Cloud (VPC). This allows you to control network access and route traffic through your VPC infrastructure while maintaining the managed benefits of Transfer Family.
This API interface reference for Transfer Family contains documentation for a programming interface that you can use to manage Transfer Family. The reference structure is as follows:
-
For the alphabetical list of API actions, see .
-
For the alphabetical list of data types, see .
-
For a list of common query parameters, see CommonParameters.
-
For descriptions of the error codes, see CommonErrors.
Rather than actually running a command, you can use the --generate-cli-skeleton parameter with any API call to generate and display a parameter template. You can then use the generated template to customize and use as input on a later command. For details, see Generate and use a parameter skeleton file.
Installing
To install this package, use the CLI of your favorite package manager:
npm install @aws-sdk/client-transferyarn add @aws-sdk/client-transferpnpm add @aws-sdk/client-transfer
Getting Started
Import
The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the TransferClient and
the commands you need, for example ListServersCommand:
// ES5 example
const { TransferClient, ListServersCommand } = require("@aws-sdk/client-transfer");
// ES6+ example
import { TransferClient, ListServersCommand } from "@aws-sdk/client-transfer";
Usage
To send a request:
- Instantiate a client with configuration (e.g. credentials, region).
- See docs/CLIENTS for configuration details.
- See @aws-sdk/config for additional options.
- Instantiate a command with input parameters.
- Call the
sendoperation on the client, providing the command object as input.
const client = new TransferClient({ region: "REGION" });
const params = { /** input parameters */ };
const command = new ListServersCommand(params);
Async/await
We recommend using the await operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
Promises
You can also use Promise chaining.
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
Aggregated client
The aggregated client class is exported from the same package, but without the "Client" suffix.
Transfer extends TransferClient and additionally supports all operations, waiters, and paginators as methods.
This style may be familiar to you from the AWS SDK for JavaScript v2.
If you are bundling the AWS SDK, we recommend using only the bare-bones client (TransferClient).
More details are in the blog post on
modular packages in AWS SDK for JavaScript.
import { Transfer } from "@aws-sdk/client-transfer";
const client = new Transfer({ region: "REGION" });
// async/await.
try {
const data = await client.listServers(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listServers(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks (not recommended).
client.listServers(params, (err, data) => {
// process err and data.
});
Troubleshooting
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
// process data.
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
/**
* The keys within exceptions are also parsed.
* You can access them by specifying exception names:
* if (error.name === 'SomeServiceException') {
* const value = error.specialKeyInException;
* }
*/
}
See also docs/ERROR_HANDLING.
Getting Help
Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
- Visit the Developer Guide or API Reference.
- Check out the blog posts tagged with
aws-sdk-json AWS Developer Blog. - Ask a question on StackOverflow and tag it with
aws-sdk-js. - Join the AWS JavaScript community on gitter.
- If it turns out that you may have found a bug, please open an issue.
To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.
Contributing
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-transfer package is updated.
To contribute to client you can check our generate clients scripts.
License
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.