使用minio搭建oss

news2024/10/6 20:41:29

文章目录

    • 1.minio安装
        • 1.拉取镜像
        • 2.启动容器
        • 3.开启端口
          • 1.9090端口
          • 2.9000端口
        • 4.访问
          • 1.网址http://:9090/
        • 5.创建一个桶
    • 2.minio文件服务基本环境搭建
        • 1.创建一个文件模块
        • 2.目录结构
        • 3.配置依赖
        • 3.application.yml 配置
        • 4.编写配置类MinioConfig.java,构建minioClient
        • 5.FileInfo.java 封装文件信息
        • 6.MinioUtil.java 文件工具类
        • 7.FileController.java 测试
        • 8.启动类 OssApplication.java
        • 9.启动测试
    • 3.传统模式
        • 1.目录结构和类图
        • 2.首先引入Lombok的依赖,使用@SneakyThrows注解抛出异常
        • 3.StorageService.java 存储的接口
        • 4.MinioStorageServiceImpl.java minio实现的接口
        • 5.如果有其他的服务比如阿里云也可以实现接口
        • 6.FileController.java 按照id来依赖注入进行调用
        • 7.测试
        • 8.缺点分析
    • 4.使用适配器模式优化
        • 1.类图
        • 2.新增一个阿里云的实现类 AliyunStorageServiceImpl.java
        • 3.抽取一个 FileService.java 构造器聚合接口
        • 4.StorageConfig.java 配置文件根据application.yml来给构造器注入不同的对象
        • 5.application.yml 指定要使用的oss
        • 6.FileController.java 组合一个FileService调用里面的方法
        • 7.测试

1.minio安装

1.拉取镜像
docker pull minio/minio

image-20240531085604926

2.启动容器
docker run -p 9000:9000 -p 9090:9090 \
 --name minio \
 -d --restart=always \
 -e "MINIO_ACCESS_KEY=" \
 -e "MINIO_SECRET_KEY=" \
 -v /mydata/minio/data:/data \
 minio/minio server \
 /data --console-address ":9090" -address ":9000"
3.开启端口
1.9090端口
systemctl start firewalld && firewall-cmd --permanent --add-port=9090/tcp && firewall-cmd --reload && firewall-cmd --query-port=9090/tcp

image-20240531090338979

2.9000端口
systemctl start firewalld && firewall-cmd --permanent --add-port=9000/tcp && firewall-cmd --reload && firewall-cmd --query-port=9000/tcp

image-20240531095156302

4.访问
1.网址http://:9090/
5.创建一个桶

image-20240531090828470

2.minio文件服务基本环境搭建

1.创建一个文件模块

image-20240531091221636

2.目录结构

image-20240531095613468

3.配置依赖
<!-- maven的配置 -->
<!-- 解决java: -source 1.5 中不支持 diamond 运算符 问题 -->
<properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.4.2</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.4.2</version>
        <exclusions>
            <exclusion>
                <artifactId>spring-boot-starter-logging</artifactId>
                <groupId>org.springframework.boot</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- minio依赖 -->
    <dependency>
        <groupId>io.minio</groupId>
        <artifactId>minio</artifactId>
        <version>8.2.0</version>
    </dependency>
</dependencies>

<!-- 配置阿里云仓库 -->
<repositories>
    <repository>
        <id>central</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<!-- maven打包常规配置 -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
3.application.yml 配置
server:
  port: 4000
minio:
  url: http://:9000
  accessKey: 
  secretKey: 
4.编写配置类MinioConfig.java,构建minioClient
package com.sunxiansheng.oss.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Description: minio配置管理
 * @Author sun
 * @Create 2024/5/31 9:22
 * @Version 1.0
 */
@Configuration
public class MinioConfig {

    // minioUrl
    @Value("${minio.url}")
    private String url;

    // minio用户名
    @Value("${minio.accessKey}")
    private String accessKey;

    // minio密码
    @Value("${minio.secretKey}")
    private String secretKey;


    /**
     * 构造minioClient
     */
    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
    }

}
5.FileInfo.java 封装文件信息
package com.sunxiansheng.oss.entity;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:47
 * @Version 1.0
 */
public class FileInfo {

    private String fileName;

    private Boolean directoryFlag;

    private String etag;

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public Boolean getDirectoryFlag() {
        return directoryFlag;
    }

    public void setDirectoryFlag(Boolean directoryFlag) {
        this.directoryFlag = directoryFlag;
    }

    public String getEtag() {
        return etag;
    }

    public void setEtag(String etag) {
        this.etag = etag;
    }
}
6.MinioUtil.java 文件工具类
package com.sunxiansheng.oss.util;

import com.sunxiansheng.oss.entity.FileInfo;
import io.minio.*;
import io.minio.messages.Bucket;
import io.minio.messages.Item;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Description: minio文件操作工具
 * @Author sun
 * @Create 2024/5/31 9:30
 * @Version 1.0
 */
@Component
public class MinioUtil {

    @Resource
    private MinioClient minioClient;

    /**
     * 创建bucket桶
     */
    public void createBucket(String bucket) throws Exception {
        boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build());
        if (!exists) {
            minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build());
        }
    }

    /**
     * 上传文件
     */
    public void uploadFile(InputStream inputStream, String bucket, String objectName) throws Exception {
        minioClient.putObject(PutObjectArgs.builder().bucket(bucket).object(objectName)
                .stream(inputStream, -1, Integer.MAX_VALUE).build());
    }

    /**
     * 列出所有桶
     */
    public List<String> getAllBucket() throws Exception {
        List<Bucket> buckets = minioClient.listBuckets();
        return buckets.stream().map(Bucket::name).collect(Collectors.toList());
    }

    /**
     * 列出当前桶及文件
     */
    public List<FileInfo> getAllFile(String bucket) throws Exception {
        Iterable<Result<Item>> results = minioClient.listObjects(
                ListObjectsArgs.builder().bucket(bucket).build());
        List<FileInfo> fileInfoList = new LinkedList<>();
        for (Result<Item> result : results) {
            FileInfo fileInfo = new FileInfo();
            Item item = result.get();
            fileInfo.setFileName(item.objectName());
            fileInfo.setDirectoryFlag(item.isDir());
            fileInfo.setEtag(item.etag());
            fileInfoList.add(fileInfo);
        }
        return fileInfoList;
    }

    /**
     * 下载文件
     */
    public InputStream downLoad(String bucket, String objectName) throws Exception {
        return minioClient.getObject(
                GetObjectArgs.builder().bucket(bucket).object(objectName).build()
        );
    }

    /**
     * 删除桶
     */
    public void deleteBucket(String bucket) throws Exception {
        minioClient.removeBucket(
                RemoveBucketArgs.builder().bucket(bucket).build()
        );
    }

    /**
     * 删除文件
     */
    public void deleteObject(String bucket, String objectName) throws Exception {
        minioClient.removeObject(
                RemoveObjectArgs.builder().bucket(bucket).object(objectName).build()
        );
    }

}
7.FileController.java 测试
package com.sunxiansheng.oss.controller;

import com.sunxiansheng.oss.util.MinioUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:53
 * @Version 1.0
 */
@RestController
public class FileController {

    @Resource
    private MinioUtil minioUtil;

    @RequestMapping("/testGetAllBuckets")
    public String testGetAllBuckets() throws Exception {
        List<String> allBucket = minioUtil.getAllBucket();
        return allBucket.get(0);
    }

}
8.启动类 OssApplication.java
package com.sunxiansheng.oss;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:20
 * @Version 1.0
 */
@SpringBootApplication
@ComponentScan("com.sunxiansheng")
public class OssApplication {
    
    public static void main(String[] args) {
        SpringApplication.run(OssApplication.class, args);
    }
}
9.启动测试

image-20240531095956479

image-20240531100012712

3.传统模式

1.目录结构和类图

image-20240531102824619

image-20240531112643283

2.首先引入Lombok的依赖,使用@SneakyThrows注解抛出异常
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.16</version>
        </dependency>
3.StorageService.java 存储的接口
package com.sunxiansheng.oss.service;

import com.sunxiansheng.oss.entity.FileInfo;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 10:03
 * @Version 1.0
 */
public interface StorageService {

    /**
     * 创建bucket桶
     */
    void createBucket(String bucket);

    /**
     * 上传文件
     */
    void uploadFile(MultipartFile uploadFile, String bucket, String objectName);

    /**
     * 列出所有桶
     */
    List<String> getAllBucket();

    /**
     * 列出当前桶及文件
     */
    List<FileInfo> getAllFile(String bucket);

    /**
     * 下载文件
     */
    InputStream downLoad(String bucket, String objectName);

    /**
     * 删除桶
     */
    void deleteBucket(String bucket);

    /**
     * 删除文件
     */
    void deleteObject(String bucket, String objectName);


}
4.MinioStorageServiceImpl.java minio实现的接口
package com.sunxiansheng.oss.service.impl;

import com.sunxiansheng.oss.entity.FileInfo;
import com.sunxiansheng.oss.service.StorageService;
import com.sunxiansheng.oss.util.MinioUtil;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 10:06
 * @Version 1.0
 */
@Service("minioStorageServiceImpl")
public class MinioStorageServiceImpl implements StorageService {
    @Resource
    private MinioUtil minioUtil;

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void createBucket(String bucket) {
        minioUtil.createBucket(bucket);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void uploadFile(MultipartFile uploadFile, String bucket, String objectName) {
        createBucket(bucket);
        if (objectName != null) {
            minioUtil.uploadFile(uploadFile.getInputStream(), bucket, objectName + "/" + uploadFile.getName());
        } else {
            minioUtil.uploadFile(uploadFile.getInputStream(), bucket, uploadFile.getName());
        }
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public List<String> getAllBucket() {
        return minioUtil.getAllBucket();
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public List<FileInfo> getAllFile(String bucket) {
        return minioUtil.getAllFile(bucket);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public InputStream downLoad(String bucket, String objectName) {
        return minioUtil.downLoad(bucket, objectName);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void deleteBucket(String bucket) {
        minioUtil.deleteBucket(bucket);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void deleteObject(String bucket, String objectName) {
        minioUtil.deleteObject(bucket, objectName);
    }
}
5.如果有其他的服务比如阿里云也可以实现接口
6.FileController.java 按照id来依赖注入进行调用
package com.sunxiansheng.oss.controller;

import com.sunxiansheng.oss.service.StorageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:53
 * @Version 1.0
 */
@RestController
public class FileController {

    // 这里根据id进行依赖注入,如果还有阿里云的,就注入阿里云的即可
    @Resource
    private StorageService minioStorageServiceImpl;

    @RequestMapping("/listBuckets")
    public String testGetAllBuckets() throws Exception {
        List<String> allBucket = minioStorageServiceImpl.getAllBucket();
        return allBucket.get(0);
    }

}
7.测试

image-20240531103457742

8.缺点分析

如果需要修改为阿里云的,则需要修改注入的id,也就是所有的controller都需要修改

4.使用适配器模式优化

1.类图

image-20240531143453159

2.新增一个阿里云的实现类 AliyunStorageServiceImpl.java
package com.sunxiansheng.oss.service.impl;

import com.sunxiansheng.oss.entity.FileInfo;
import com.sunxiansheng.oss.service.StorageService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 11:13
 * @Version 1.0
 */
@Service("aliyunStorageServiceImpl")
public class AliyunStorageServiceImpl implements StorageService {
    @Override
    public void createBucket(String bucket) {

    }

    @Override
    public void uploadFile(MultipartFile uploadFile, String bucket, String objectName) {

    }

    @Override
    public List<String> getAllBucket() {
        List<String> res = new ArrayList<>();
        res.add("aliyunBucket");
        return res;
    }

    @Override
    public List<FileInfo> getAllFile(String bucket) {
        return Collections.emptyList();
    }

    @Override
    public InputStream downLoad(String bucket, String objectName) {
        return null;
    }

    @Override
    public void deleteBucket(String bucket) {

    }

    @Override
    public void deleteObject(String bucket, String objectName) {

    }
}

3.抽取一个 FileService.java 构造器聚合接口
package com.sunxiansheng.oss.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 10:48
 * @Version 1.0
 */
@Service
public class FileService {

    private final StorageService storageService;

    @Autowired // 构造器注入,如果只有一个构造器,其实可以不加,会自动识别
    public FileService(StorageService storageService) {
        this.storageService = storageService;
    }

    /**
     * 列出所有桶
     */
    public List<String> getAllBucket() {
        return storageService.getAllBucket();
    }

}

4.StorageConfig.java 配置文件根据application.yml来给构造器注入不同的对象
package com.sunxiansheng.oss.config;

import com.sunxiansheng.oss.service.StorageService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 11:10
 * @Version 1.0
 */
@Configuration
public class StorageConfig {

    @Value("${storage.service.type}")
    private String storageType;

    @Resource
    private StorageService aliyunStorageServiceImpl;

    @Resource
    private StorageService minioStorageServiceImpl;

    @Bean
    public StorageService storageService() {
        if ("minio".equals(storageType)) {
            return minioStorageServiceImpl;
        } else if ("aliyun".equals(storageType)) {
            return aliyunStorageServiceImpl;
        } else {
            throw new IllegalArgumentException("未找到对应的文件存储处理");
        }
    }


}
5.application.yml 指定要使用的oss
6.FileController.java 组合一个FileService调用里面的方法
package com.sunxiansheng.oss.controller;

import com.sunxiansheng.oss.service.FileService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:53
 * @Version 1.0
 */
@RestController
public class FileController {

    // 这里根据id进行依赖注入,如果还有阿里云的,就注入阿里云的即可
    @Resource
    private FileService fileService;

    @RequestMapping("/listBuckets")
    public String testGetAllBuckets() throws Exception {
        List<String> allBucket = fileService.getAllBucket();
        return allBucket.get(0);
    }

}
7.测试

image-20240531143928470

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1873959.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Python】已解决:Python正确安装文字识别库EasyOCR

文章目录 一、分析问题背景二、可能出错的原因三、错误代码示例四、正确代码示例五、注意事项 已解决&#xff1a;Python正确安装文字识别库EasyOCR 一、分析问题背景 在使用Python进行图像处理和文字识别时&#xff0c;EasyOCR是一个流行的库&#xff0c;它基于PyTorch&…

一大波客户感谢信来袭,感谢认可!

“自美的置业数据中台项目启动以来&#xff0c;贵公司实施团队与服务运营始终以专业、敬业、合作的态度扎根用户、服务用户、与用户共成长。在此&#xff0c;我司表示由衷的感谢&#xff01;” 这是携手美的置业以来&#xff0c;我们收到的第二封客户感谢信。 △ 以上为美的置…

Vue2组件传值(通信)的方式

1.父传后代 ( 后代拿到了父的数据 ) 1. 父组件引入子组件&#xff0c;绑定数据 <List :str1‘str1’></List> 子组件通过props来接收props:{str1:{type:String,default:}}***这种方式父传子很方便&#xff0c;但是父传给孙子辈分的组件就很麻烦&#xff08;父》子…

PerplexityAI与《连线》杂志纠纷事件深度分析

引言 最近&#xff0c;PerplexityAI&#xff0c;这家人工智能搜索领域的新秀公司&#xff0c;因被《连线》杂志指控剽窃内容和捏造事实而陷入困境。这起事件引发了广泛关注&#xff0c;也揭示了AI技术在信息检索和内容生成领域面临的一系列挑战。本文将对该事件进行详细分析&a…

《昇思25天学习打卡营第5天|onereal》

ShuffleNet网络介绍 ShuffleNetV1是旷视科技提出的一种计算高效的CNN模型&#xff0c;和MobileNet, SqueezeNet等一样主要应用在移动端&#xff0c;所以模型的设计目标就是利用有限的计算资源来达到最好的模型精度。ShuffleNetV1的设计核心是引入了两种操作&#xff1a;Pointw…

KVB外汇:澳元/美元、澳元/纽元、英镑/澳元的走势如何?

摘要 本文对近期澳元/美元、澳元/纽元、英镑/澳元的技术走势进行了详细分析。通过对关键支撑位和阻力位的分析&#xff0c;我们可以更好地理解澳元在不同货币对中的表现。随着全球经济形势的变化&#xff0c;各国央行的货币政策对外汇市场的影响也愈发明显。本文旨在帮助投资者…

centos7+离线安装nginx

1.提取rpm包 链接&#xff1a;https://pan.baidu.com/s/1qLNPubAD_qt59Pzws4nnog 提取码&#xff1a;0124 --来自百度网盘超级会员V3的分享 2.安装流程 rpm -ivh nginx-1.20.1-1.el7.ngx.x86_64.rpm 在使用 nginx 时&#xff0c;通常需要掌握一些基本的命令来管理其启动、查…

新能源行业必会基础知识-----电力市场概论笔记-----经济学基础

新能源行业知识体系-------主目录-----持续更新(进不去说明我没写完)&#xff1a;https://blog.csdn.net/grd_java/article/details/139946830 目录 1. 什么是市场2. 电力市场机制设计的基本要求 1. 什么是市场 经济学定义 市场是供需双方交易并决定商品价格和产量的机制市场可…

新学期必备,录取情况统计如何制作?

暑假即将开始&#xff0c;新学期离我们又近了一步&#xff0c;老师们是不是在为如何高效统计录取情况而头疼呢&#xff1f;别担心&#xff0c;分享一个超实用的小技巧——使用易查分小程序的新建填表功能&#xff0c;让你的录取统计工作变得简单又高效&#xff01; 打开易查分小…

汇总大语言模型LLM的评测基准数据集(BenchMarks)

文章目录 0. 引言1. 知识与语言理解1.1 MMLU1.2 ARC1.3 GLUE1.4 Natural Questions1.5 LAMBADA1.5 HellaSwag1.6 MultiNLI1.7 SuperGLUE1.8 TriviaQA1.9 WinoGrande1.10 SciQ 2. 推理能力2.1 GSM8K2.2 DROP2.3 CRASS2.4 RACE2.5 BBH2.6 AGIEval2.7 BoolQ 3. 多轮开放式对话3.1 …

一文弄懂梯度下降算法

1、引言 在上一篇文章中&#xff0c;我们介绍了如何使用线性回归和成本损失函数为房价数据找到最拟合的线。不过&#xff0c;我们也看到&#xff0c;测试多个截距值可能既繁琐又低效。在本文中&#xff0c;我们将深入探讨梯度下降算法&#xff0c;这是一种更加强大的技术&…

three.js场景三元素

three.js是一个基于WebGL的轻量级、易于使用的3D库。它极大地简化了WebGL的复杂细节&#xff0c;降低了学习成本&#xff0c;同时提高了性能。 three.js的三大核心元素&#xff1a; 场景&#xff08;Scene&#xff09; 场景是一个三维空间&#xff0c;是所有物品的容器。可以将…

桌面提醒工具哪个好?简单好用的便签提醒app推荐

在日常的生活和工作中&#xff0c;我们经常会遇到各种各样的事情&#xff0c;有时候可能会遗忘一些重要的事情。这个时候&#xff0c;一个简单好用的便签提醒工具就显得尤为重要了。那么&#xff0c;哪款桌面提醒工具比较好用呢&#xff1f;下面&#xff0c;就为大家推荐一款我…

新手教程系列 -- SQLAlchemy对同一张表联表两次

在开发过程中,我们经常会遇到对同一张表进行多次联表查询的需求。比如在查询航线时,我们希望将起飞和降落的机场名称代入结果中。为了实现这一目标,机场名称统一存放在 AirPort 表中。下面,我们将介绍如何通过 SQLAlchemy 实现这一需求。 问题描述 一般情况我们第一时间会…

AI 激发算力需求暴增,施耐德电气解码智算中心发展

随着全球碳达峰目标的持续推进&#xff0c;各行各业都在加速绿色转型的步伐&#xff0c;尤其是高耗能产业更是备受关注。人工智能行业以其迅猛的发展速度令人瞩目&#xff0c;它所带来的不仅是算力需求的飙升&#xff0c;更是日益凸显的能耗问题。 目前&#xff0c;人工智能预…

11.常见的Transforms(二)

常见的Transforms&#xff08;二&#xff09; 1.Resize() 的使用 1.1 作用 resize可以把输入的图片按照输入的参数值重新设定大小。 1.2 所需参数 需要输入想要重新设定的图片大小。 输入的参数类型可以为包含长和宽数值的一个序列&#xff08;h,w&#xff09;或者一个整…

grpc学习golang版( 八、双向流示例 )

系列文章目录 第一章 grpc基本概念与安装 第二章 grpc入门示例 第三章 proto文件数据类型 第四章 多服务示例 第五章 多proto文件示例 第六章 服务器流式传输 第七章 客户端流式传输 第八章 双向流示例 文章目录 一、前言二、定义proto文件三、编写server服务端四、编写client客…

远程监控在工业机械安全操作中的应用——以汽车起重机为例

远程监控技术&#xff0c;作为现代信息技术的重要分支&#xff0c;正逐渐在各个领域展现其独特的价值。从字面上理解&#xff0c;远程监控可以分为“监”和“控”两部分&#xff1a;其中&#xff0c;“监”指的是通过网络进行信息的获取与传递&#xff0c;实现远程状态的实时感…

Dominate_一个用于生成和操作 HTML 文档的 Python 库

目录 01初识 Dominate 什么是 Dominate&#xff1f; 为什么选择 Dominate&#xff1f; 安装与配置 02Dominate 的基本使用 创建简单的 HTML 文档 添加表格 嵌套结构 03Dominate 的高级功能 动态内容生成 使用…

第十九课,编写并调用自定义函数

一&#xff0c;函数五大组成部分 因为其重要性故再此强调&#xff0c;参数列表可以为任意个数&#xff0c;返回值只能有一个&#xff08;请初学者暂时这样认为&#xff09; 特殊的&#xff0c;如果不需要返回结果&#xff0c;用None替代&#xff01; 二&#xff0c;编写自定义…