zoukankan      html  css  js  c++  java
  • boto3库限速

    # -*- coding: utf-8 -*-
    import boto3
    from boto3.s3.transfer import TransferConfig
    # from s3transfer.manager import TransferConfig
    access_key = "xxx"
    secret_key = "xxx"
    
    cli = boto3.client(
        's3',
        aws_access_key_id=access_key,
        aws_secret_access_key=secret_key,
        endpoint_url='http://ss.bscstorage.com'
    )
    
    config = TransferConfig(
        multipart_threshold=30 * 1024 * 1024,
        multipart_chunksize=8 * 1024 * 1024,
        max_concurrency=10,
    )
    
    # 50MB/s
    # 单位是byte
    config.max_bandwidth =  50 * 1024 * 1024
    
    
    resp = cli.upload_file(
        '/tmp/VSCode-darwin-stable.zip',
        'test',
        'test-key-xx2',
        ExtraArgs={
            'ContentType': 'text/plain', # 请替换为合适的文件类型
            'ACL': 'private',
        },
        Config=config
    )
    

      

  • 相关阅读:
    带你走进Ajax
    基础
    基础
    基础-文字
    C++ part6.5
    操作系统 part4
    操作系统 part3
    计算机网络 part3 HTTP&HTTPS
    计算机网络 part2
    计算机网络 part1 TCP
  • 原文地址:https://www.cnblogs.com/liujiliang/p/10330492.html
Copyright © 2011-2022 走看看