我在Python2.7中有一个AWS Glue作业,该作业试图将文件从我的s3存储桶ftp到客户端服务器。我正在使用pythons内置的ftplib库来执行此操作。只要文件小于2GB,我就能通过ftp传输文件。当文件大小超过2GB时,它将失败并显示以下错误
cat:precision-error-tmp-file.txt:没有此类文件或目录
我尝试更改块大小,但这无济于事
def upload_from_s3_ftplib(s3_bucket, s3_file, ftp_host, ftp_username,
ftp_password, ftp_directory):
"""Uploads the given file at the given S3 URL to the given FTP server
using the ftplib library"""
file_name = ntpath.basename(s3_file)
logger.info(" file name {}".format(file_name))
ftp = FTP(ftp_host)
logger.info("Connected")
ftp.login(user=ftp_username, passwd=ftp_password)
logger.info("Login Successful")
if ftp_directory.strip() <> '':
ftp.cwd(ftp_directory)
logger.info('Working directory changed to {}'.format(ftp_directory))
logger.info("Transfer file remote FTP {}".format(ftp_directory + "/" + s3_file))
s3 = boto3.resource('s3')
obj = s3.Object(s3_bucket, s3_file)
body = obj.get()['Body'].read()
ftp.storbinary('STOR {}'.format(file_name), BytesIO(body))
logger.info('File transmitted!!!')
ftp.quit()