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的传输以便文件的访问权限。

相关内容

热门资讯

透视分享!wepoker有机器... 透视分享!wepoker有机器人吗(透视)德州之星扫描器,教程窍要(有挂辅助)-哔哩哔哩1、打开软件...
透视透视!德普之星辅助器怎么用... 透视透视!德普之星辅助器怎么用(透视)安装不了wepoker,教程技法(有人有挂)-哔哩哔哩1、在德...
透视解迷!wepoker有没有... 透视解迷!wepoker有没有挂(透视)wepoker怎么设置房间,教程模块(有挂透明挂)-哔哩哔哩...
透视总结!wepoker开辅助... 透视总结!wepoker开辅助能查到吗(透视)wepoker有辅助工具吗,教程机巧(有挂详情)-哔哩...
透视必备!wpk透视辅助下载(... 透视必备!wpk透视辅助下载(透视)wepoker黑侠辅助器,教程妙计(有挂工具)-哔哩哔哩运wep...
透视分享!xpoker辅助工具... 透视分享!xpoker辅助工具(透视)pokernow辅助工具,教程窍要(有挂工具)-哔哩哔哩1、p...
透视详情!pokernow辅助... 透视详情!pokernow辅助控制(透视)hh poker透视器下载,教程妙招(有挂神器)-哔哩哔哩...
透视揭露!cloudpoker... 透视揭露!cloudpoker开挂(透视)pokemmo脚本最新版,教程资料(有挂透明挂)-哔哩哔哩...
透视解迷!德州局怎么透视(透视... 透视解迷!德州局怎么透视(透视)wepoker公共底牌,教程方案(有挂分析)-哔哩哔哩小薇(辅助器软...
透视专业!wepoker轻量版... 透视专业!wepoker轻量版透视(透视)hhpoker视频巡查真的假的,教程举措(有挂透视)-哔哩...