Skip to content
Get Started for Free

Transfer

The AWS Transfer API is a powerful tool that empowers users to establish FTP(S) servers with ease. These servers serve as gateways, allowing direct access to files residing in Amazon S3 buckets. This functionality streamlines file management processes, making it simpler and more efficient to handle data stored in S3 by providing a familiar FTP interface for users to interact with their files securely. Whether you’re looking to facilitate file transfers or enhance your data access capabilities, the AWS Transfer API simplifies the process and extends the versatility of your cloud storage infrastructure.

This Python code demonstrates a basic workflow for transferring a file between a local machine and AWS S3 using the AWS Transfer Family service and FTP (File Transfer Protocol).

import io
import time
import uuid
import boto3
from ftplib import FTP, FTP_TLS
EDGE_URL = 'http://localhost:4566'
USERNAME = 'user_123'
BUCKET = 'transfer-files'
S3_FILENAME = 'test-file-aws-transfer.txt'
FTP_USER_DEFAULT_PASSWD = '12345'
FILE_CONTENT = b'title "Test" \nfile content!!'
# create bucket
s3_client = boto3.client('s3', endpoint_url=EDGE_URL)
s3_client.create_bucket(Bucket=BUCKET)
transfer_client = boto3.client('transfer', endpoint_url=EDGE_URL)
# create transfer server
rs = transfer_client.create_server(
EndpointType='PUBLIC',
IdentityProviderType='SERVICE_MANAGED',
Protocols=['FTP']
)
time.sleep(1)
server_id = rs['ServerId']
port = int(server_id[-4:])
transfer_client.create_user(
ServerId=server_id,
HomeDirectory=BUCKET,
HomeDirectoryType='PATH',
Role='arn:aws:iam::testrole',
UserName=USERNAME
)
# upload file through AWS Transfer
ftp = FTP()
ftp.connect('localhost', port=port)
result = ftp.login(USERNAME, FTP_USER_DEFAULT_PASSWD)
assert 'Login successful.' in result
ftp.storbinary(cmd='STOR %s' % S3_FILENAME, fp=io.BytesIO(FILE_CONTENT))
ftp.quit()
# download file through AWS S3
rs = s3_client.get_object(Bucket=BUCKET, Key=S3_FILENAME)
assert rs['Body'].read() == FILE_CONTENT

Please note that this code is a simplified example for demonstration purposes. In a production environment, you should use more secure practices, including setting proper IAM roles and handling sensitive credentials securely. Additionally, error handling and cleanup code may be needed to ensure the script behaves robustly in all scenarios.

The Transfer API does not provide a way to return the endpoint URL of created FTP servers. Hence, in order to determine the server endpoint, the local port is encoded as a suffix within the ServerId attribute, constituting the only numeric digits within the ID string. For example, assume the following is the response from the CreateServer API call, then the FTP server is accessible on port 4511 (i.e., ftp://localhost:4511):

Output
{
"ServerId": "s-afcedbffaecca4511"
}

14 of 71 operations implemented

Available from the Ultimate plan. Licensing details

Find an API

Search the full operation list, then sort the table to compare current support.

Loading operations…

Verified on Kubernetes
Loading operations…
Complete static API list All 71 operations and their current support status
OperationStatus
CreateAccessNot implemented
CreateAgreementNot implemented
CreateConnectorNot implemented
CreateProfileNot implemented
CreateServerImplemented
CreateUserImplemented
CreateWebAppNot implemented
CreateWorkflowNot implemented
DeleteAccessNot implemented
DeleteAgreementNot implemented
DeleteCertificateNot implemented
DeleteConnectorNot implemented
DeleteHostKeyNot implemented
DeleteProfileNot implemented
DeleteServerImplemented
DeleteSshPublicKeyImplemented
DeleteUserImplemented
DeleteWebAppNot implemented
DeleteWebAppCustomizationNot implemented
DeleteWorkflowNot implemented
DescribeAccessNot implemented
DescribeAgreementNot implemented
DescribeCertificateNot implemented
DescribeConnectorNot implemented
DescribeExecutionNot implemented
DescribeHostKeyNot implemented
DescribeProfileNot implemented
DescribeSecurityPolicyNot implemented
DescribeServerImplemented
DescribeUserImplemented
DescribeWebAppNot implemented
DescribeWebAppCustomizationNot implemented
DescribeWorkflowNot implemented
ImportCertificateNot implemented
ImportHostKeyNot implemented
ImportSshPublicKeyImplemented
ListAccessesNot implemented
ListAgreementsNot implemented
ListCertificatesNot implemented
ListConnectorsNot implemented
ListExecutionsNot implemented
ListFileTransferResultsNot implemented
ListHostKeysNot implemented
ListProfilesNot implemented
ListSecurityPoliciesNot implemented
ListServersImplemented
ListTagsForResourceNot implemented
ListUsersImplemented
ListWebAppsNot implemented
ListWorkflowsNot implemented
SendWorkflowStepStateNot implemented
StartDirectoryListingNot implemented
StartFileTransferNot implemented
StartRemoteDeleteNot implemented
StartRemoteMoveNot implemented
StartServerImplemented
StopServerImplemented
TagResourceNot implemented
TestConnectionNot implemented
TestIdentityProviderNot implemented
UntagResourceNot implemented
UpdateAccessNot implemented
UpdateAgreementNot implemented
UpdateCertificateNot implemented
UpdateConnectorNot implemented
UpdateHostKeyNot implemented
UpdateProfileNot implemented
UpdateServerImplemented
UpdateUserImplemented
UpdateWebAppNot implemented
UpdateWebAppCustomizationNot implemented
Was this page helpful?