ASWDataSync-在DataSync任务执行期间添加文件的情景
创始人
2024-09-20 23:01:13
0

AWS DataSync是一种服务,可以在AWS中安全快速地传输数据。使用AWS DataSync可以在两个地点之间安全地传输和同步文件,S3存储桶和EFS存储卷。如果需要在DataSync任务执行期间添加文件,则可以使用AWS SDK for Python(Boto3)来完成此操作。

以下示例代码演示如何在DataSync任务执行期间添加文件:

import boto3

client = boto3.client('datasync')

# Start a DataSync task
response = client.start_task_execution(
    TaskArn='',
    OverrideOptions={
        'VerifyMode': 'ONLY_FILES_TRANSFERRED',
        #add ACL for the file using below option
        'Atime': 'NONE',
        'Mtime': 'NONE',
        'Uid': 'NONE',
        'Gid': 'NONE',
        'PreserveDeletedFiles': 'PRESERVE',
        'PreserveDevices': 'NONE',
        'PosixPermissions': 'NONE',
        'BytesPerSecond': 268435456
    }
)

# Add a new file to the source location while the task is executing
result = client.create_location_object_storage(
    ServerHostname='',
    ServerPort=,
    ServerProtocol='HTTPS',
    BucketName='',
    AccessKey='',
    SecretKey=''
)

# Get the location ARN of the source object storage location
location_source_arn = result['LocationArn']

# Generate a list of dict objects representing the files to be transferred
transfer_list = [
    {
        'SourceLocationArn': location_source_arn,
        'DestinationLocationArn': '',
        'OverwriteMode': 'ALWAYS',
        'Source': {
            'BucketName': '',
            'Key': '',
        },
    }
]

# Add the new file to the list of files to be transferred
response = client.update_task(
    TaskArn='',
    Includes={
        'Files': transfer_list
    }
)

在上面的示例代码中,我们启动了一个传输任务,然后在任务执行期间添加了文件。您可以通过“update_task”函数将文件添加到待传输文件的列表中。同时,您还可以使用“OverrideOptions”参数控制ACL的传输以便文件的访问权限。

相关内容

热门资讯

第四分钟辅助!hhpoker辅... 第四分钟辅助!hhpoker辅助器,wepoker免费辅助器,演示教程(有人有挂)1、实时wepok...
1分钟辅助!wepoker可以... 1分钟辅助!wepoker可以免费玩吗,德州局脚本,手筋教程(有挂猫腻)1、任何wepoker可以免...
6分钟辅助!wejoker私人... 6分钟辅助!wejoker私人辅助软件,wepoker安装教程,技法教程(有挂技巧)1、wejoke...
第六分钟辅助!wepoker手... 第六分钟辅助!wepoker手机版辅助,wepoker能不能透视,指引教程(今日头条)1、该软件可以...
第五分钟辅助!wepoker透... 第五分钟辅助!wepoker透视有没有,we poker辅助器下载,资料教程(有人有挂)1、进入游戏...
第九分钟辅助!aapoker安... 第九分钟辅助!aapoker安装包怎么使用,wepoker俱乐部辅助器,教材教程(真的有挂)1、超多...
一分钟辅助!wepoker游戏... 一分钟辅助!wepoker游戏下载,pokemmo脚本,资料教程(有挂方法)1、在wepoker游戏...
四分钟辅助!约局吧开挂神器是真... 四分钟辅助!约局吧开挂神器是真的吗,哈糖大菠萝开挂,教材教程(揭秘有挂)1)约局吧开挂神器是真的吗辅...
8分钟辅助!wpk辅助器,wp... 8分钟辅助!wpk辅助器,wpk可以作弊吗,法子教程(有挂助手)1、让任何用户在无需wpk可以作弊吗...
9分钟辅助!aapoker如何... 9分钟辅助!aapoker如何设置胜率,aapoker破解侠是真的吗,指引教程(有挂教学)1、aap...