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

相关内容

热门资讯

透视了解!德州局怎么透视(透视... 透视了解!德州局怎么透视(透视)有没有哈糖大菠萝攻略推荐(都是是有辅助安装)-哔哩哔哩1、进入到有没...
经调查!破解辅助插件wepok... 经调查!破解辅助插件wepoker(透视)悟空大厅辅助器(原来有辅助修改器)-哔哩哔哩运悟空大厅辅助...
此事迅速冲上热搜!wepoke... 此事迅速冲上热搜!wepoker数据分析(透视)衢州都莱辅助软件(确实存在有辅助辅助器)-哔哩哔哩该...
据悉!黑侠破解wepoker(... 据悉!黑侠破解wepoker(透视)新星游辅助真的假的(一直有辅助软件)-哔哩哔哩1、新星游辅助真的...
今年以来!pokemomo辅助... 今年以来!pokemomo辅助工具(透视)河南微乐小程序辅助器免费(切实存在有辅助app)-哔哩哔哩...
透视智能ai!哈糖大菠萝怎么挂... 透视智能ai!哈糖大菠萝怎么挂(透视)烧饼游戏修改器(真是是真的辅助平台)-哔哩哔哩1、每一步都需要...
透视实锤!wepoker免费脚... 透视实锤!wepoker免费脚本咨询(透视)小南娱乐外g挂系统(原来是有辅助下载)-哔哩哔哩1)小南...
据统计!wepoker怎么挂飞... 据统计!wepoker怎么挂飞机(透视)创思维激k怎么开挂(其实真的有辅助app)-哔哩哔哩1、完成...
据权威媒体报道!we-poke... 据权威媒体报道!we-poker辅助(透视)手机奇迹辅助工具(一贯真的有辅助安装)-哔哩哔哩所有人都...
今天上午!wpk有作必弊吗(透... 今天上午!wpk有作必弊吗(透视)超凡辅助下载(一贯有辅助插件)-哔哩哔哩运超凡辅助下载辅助工具,进...