首页 > 编程语言 >python之minio基础操作(二)

python之minio基础操作(二)

时间:2023-06-08 09:44:18浏览次数:32  
标签:object minio python xxx file time 操作 name

from minio import Minio
from multiprocessing import Process
import time


def upload_file():
    # 创建minio客户端
    client = Minio(endpoint="xxx.xxx.xxx.xxx:xxx",
                   access_key='xxx',
                   secret_key='xxx',
                   secure=False  # 使用http
                   )

    file_name = '19d5c50e833d4fa8af3b7412d40000a2.jpg'
    file_path = r'E:\集成资料\视频素材'
    barrel = "testdata"
    for i in range(6000):

        client.fput_object(bucket_name=barrel, object_name="data1/" + str(i) + file_name,
                           file_path=file_path + "/" + file_name)
    stop_time = time.strftime("%y-%m-%d: %H:%M:%S", time.localtime())
    print(stop_time)


def download_file():
    # 创建minio客户端
    client = Minio(endpoint="xxx.xxx.xxx.xxx:xxx",
                   access_key='xxx',
                   secret_key='xxx',
                   secure=False  # 使用http
                   )
    file_path = r'E:/集成资料/测试项目/minio/'
    barrel = "testdata"
    files = client.list_objects(barrel, prefix="data1/")
    for file in files:
        client.fget_object(bucket_name=barrel, object_name=file.object_name,
                           file_path=file_path + str(file.object_name))

    stop_time = time.strftime("%y-%m-%d: %H:%M:%S", time.localtime())
    print(stop_time)


if __name__ == '__main__':
    thread_pool = list()
    for a in range(20):
        name = Process(target=download_file())
        thread_pool.append(name)
    for t in thread_pool:
        t.start()
        print("线程{}执行中".format(t))
        print(time.strftime("%y-%m-%d: %H:%M:%S", time.localtime()))
    for t in thread_pool:
        t.join()

 

标签:object,minio,python,xxx,file,time,操作,name
From: https://www.cnblogs.com/mian-1122/p/17463918.html

相关文章

  • python之minio基础操作(一)
    fromminioimportMiniofile_name='3e09ca66d9444906935b0171e26891f1.mp4'file_path=r'E:\集成资料\视频素材'barrel="testdata"defupload_file():#创建minio客户端client=Minio(endpoint="xxx.xxx.xxx.xxx:xxxxx"......
  • 【python基础】循环语句-for循环
    1.初始for循环for循环可以遍历任何可迭代对象,如一个列表或者一个字符串。这里可迭代对象的概念我们后期介绍,先知道这个名词就好了。其语法格式之一:比如我们遍历学员名单,编写程序如下所示:for循环如果放在生产生活中的话,也类似于循环处理,但较while循环有区别,其区别就在于条件......
  • 1.ES入门与基本操作
    1.介绍与安装1.1.ElasticStack核心TheElasticStack,包括Elasticsearch、Kibana、Beats和Logstash(也称为ELKStack)。能够安全可靠地获取任何来源、任何格式的数据,然后实时地对数据进行搜索、分析和可视化。ES(ElaticSearch)是一个开源的高扩展的分布式全文搜索引擎,是整个Elas......
  • python 中统计指定字符串出现的次数
     001、>>>str1="abcdaaab"##测试字符串>>>str1.count("a")##统计a出现的次数4>>>str1.count("b")2>>>str1.count("c")1>>>str1.count("a",0,4)......
  • 2023年5月31号聊一下今天以及最近的操作与感想!
    今天操作白糖日线向下,所以它稍微有点向下的趋势我就空了,最多浮亏1800,后面看到回本就跑了......
  • python 中字符串大小写的转换
     001、全部转换为大写、或者全部转换为小写>>>str1="abcDEFgh">>>str1.lower()###小写'abcdefgh'>>>str1.upper()##大写'ABCDEFGH'>>>str1'abcDEFgh'>>>str1.casefo......
  • python读txt文档-多列
    有一个txt格式的文本文档,格式如下。有两行数据。3个字段,字段与字段直接使用tab键分割开。hello1world1hellothankyou1hello2world2hellothankyou2现在想通过python读取这个文件。分别读取到hello1,world1,和 hellothankyou1代码如下。withopen('......
  • 混合编程python与C++
    上个版本:只是用到ctypes进行传输,这次将python服务端更改为C++服务端,方便后续维护.本文实现功能:python传输图片给C++,C++接受图片后对图片进行处理,并将结果返回给python客户端,passimagefrompythontoC++C++服务端.h文件注意文中的model//.h#pragmaonce#in......
  • Python设计模式-01工厂模式
    工厂模式工厂模式(FactoryPattern)是一种创建型设计模式,它提供了一种创建对象的最佳方式,而无需指定将要创建的对象的确切类。工厂模式通过定义一个工厂接口来创建对象,让子类决定实例化哪个类。这样可以将对象的创建与使用分离,从而降低系统的耦合度。工厂模式包含三种角色:具体工......
  • python opencv图片旋转任意角度
    pythonopencv图片旋转任意角度 importcv2#Loadtheimageimg=cv2.imread("20230222100736979.jpg")#Gettheimagedimensionsheight,width=img.shape[:2]#Settherotationangleangle=25#Calculatetherotationmatrixrotation_matrix=cv2......