当前位置: 首页 > news >正文

国内网站制作欣赏百度海外视频网站建设

国内网站制作欣赏,百度海外视频网站建设,购物网站的首页是静态,网络营销对于个人而言有什么作用目录 拉取docker镜像 minio所需要的依赖 文件存放的位置 手动上传文件到minio中 工具类上传 yml配置 config类 service类 启动类 测试类 图片 视频 删除minio服务器的文件 下载minio服务器的文件 拉取docker镜像 拉取稳定版本:docker pull minio/minio:RELEASE.20…目录 拉取docker镜像 minio所需要的依赖 文件存放的位置 手动上传文件到minio中 工具类上传 yml配置 config类 service类 启动类 测试类 图片 视频 删除minio服务器的文件 下载minio服务器的文件 拉取docker镜像 拉取稳定版本:docker pull minio/minio:RELEASE.2021-06-17T00-10-46Z-28-gac7697426创建并运行容器 docker run -d -p 9000:9000 --name minio \-e MINIO_ACCESS_KEYminio \-e MINIO_SECRET_KEYminio123 \-v /path/to/data:/data \-v /path/to/config:/root/.minio \minio/minio:RELEASE.2021-06-17T00-10-46Z server /data访问minmo系统 http://192.168.74.128:9000 minio所需要的依赖 dependencygroupIdio.minio/groupIdartifactIdminio/artifactIdversion7.1.0/version/dependency 文件存放的位置 退出minio容器 exit 手动上传文件到minio中 public static void main(String[] args) {FileInputStream fileInputStream null;try {fileInputStream new FileInputStream(e:\\index.js);;//1.创建minio链接客户端MinioClient minioClient MinioClient.builder().credentials(minio, minio123).endpoint(http://192.168.74.128:9000).build();//2.上传PutObjectArgs putObjectArgs PutObjectArgs.builder().object(plugins/js/index.js)//文件名.contentType(text/js)//文件类型.bucket(leadnews)//桶名词 与minio创建的名词一致.stream(fileInputStream, fileInputStream.available(), -1) //文件流.build();minioClient.putObject(putObjectArgs);} catch (Exception ex) {ex.printStackTrace();}} 工具类上传 yml配置 minio:accessKey: miniosecretKey: minio123bucket: leadnewsendpoint: http://192.168.74.128:9000readPath: http://192.168.74.128:9000 config类 package com.heima.file.config;import com.heima.file.service.FileStorageService; import io.minio.MinioClient; import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;Data Configuration EnableConfigurationProperties({MinIOConfigProperties.class}) //当引入FileStorageService接口时 ConditionalOnClass(FileStorageService.class) public class MinIOConfig {Autowiredprivate MinIOConfigProperties minIOConfigProperties;Beanpublic MinioClient buildMinioClient() {return MinioClient.builder().credentials(minIOConfigProperties.getAccessKey(), minIOConfigProperties.getSecretKey()).endpoint(minIOConfigProperties.getEndpoint()).build();} } package com.ma.config;import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties;import java.io.Serializable;Data ConfigurationProperties(prefix minio) // 文件上传 配置前缀file.oss public class MinIOConfigProperties implements Serializable {private String accessKey;private String secretKey;private String bucket;private String endpoint;private String readPath; }service类 package com.ma.service;import java.io.InputStream;/*** author itheima*/ public interface FileStorageService {/*** 上传图片文件* param prefix 文件前缀* param filename 文件名* param inputStream 文件流* return 文件全路径*/public String uploadImgFile(String prefix, String filename,InputStream inputStream);/*** 上传html文件* param prefix 文件前缀* param filename 文件名* param inputStream 文件流* return 文件全路径*/public String uploadHtmlFile(String prefix, String filename,InputStream inputStream);/*** 删除文件* param pathUrl 文件全路径*/public void delete(String pathUrl);/*** 下载文件* param pathUrl 文件全路径* return**/public byte[] downLoadFile(String pathUrl);}package com.ma.service.impl;import com.ma.config.MinIOConfig; import com.ma.config.MinIOConfigProperties; import com.ma.service.FileStorageService; import io.minio.GetObjectArgs; import io.minio.MinioClient; import io.minio.PutObjectArgs; import io.minio.RemoveObjectArgs; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils;import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date;Slf4j EnableConfigurationProperties(MinIOConfigProperties.class) Import(MinIOConfig.class) Service public class MinIOFileStorageService implements FileStorageService {Autowiredprivate MinioClient minioClient;Autowiredprivate MinIOConfigProperties minIOConfigProperties;private final static String separator /;/*** param dirPath* param filename yyyy/mm/dd/file.jpg* return*/public String builderFilePath(String dirPath,String filename) {StringBuilder stringBuilder new StringBuilder(50);if(!StringUtils.isEmpty(dirPath)){stringBuilder.append(dirPath).append(separator);}SimpleDateFormat sdf new SimpleDateFormat(yyyy/MM/dd);String todayStr sdf.format(new Date());stringBuilder.append(todayStr).append(separator);stringBuilder.append(filename);return stringBuilder.toString();}/*** 上传图片文件* param prefix 文件前缀* param filename 文件名* param inputStream 文件流* return 文件全路径*/Overridepublic String uploadImgFile(String prefix, String filename,InputStream inputStream) {String filePath builderFilePath(prefix, filename);try {PutObjectArgs putObjectArgs PutObjectArgs.builder().object(filePath).contentType(image/jpg).bucket(minIOConfigProperties.getBucket()).stream(inputStream,inputStream.available(),-1).build();minioClient.putObject(putObjectArgs);StringBuilder urlPath new StringBuilder(minIOConfigProperties.getReadPath());urlPath.append(separatorminIOConfigProperties.getBucket());urlPath.append(separator);urlPath.append(filePath);return urlPath.toString();}catch (Exception ex){log.error(minio put file error.,ex);throw new RuntimeException(上传文件失败);}}/*** 上传html文件* param prefix 文件前缀* param filename 文件名* param inputStream 文件流* return 文件全路径*/Overridepublic String uploadHtmlFile(String prefix, String filename,InputStream inputStream) {String filePath builderFilePath(prefix, filename);try {PutObjectArgs putObjectArgs PutObjectArgs.builder().object(filePath).contentType(text/html).bucket(minIOConfigProperties.getBucket()).stream(inputStream,inputStream.available(),-1).build();minioClient.putObject(putObjectArgs);StringBuilder urlPath new StringBuilder(minIOConfigProperties.getReadPath());urlPath.append(separatorminIOConfigProperties.getBucket());urlPath.append(separator);urlPath.append(filePath);return urlPath.toString();}catch (Exception ex){log.error(minio put file error.,ex);ex.printStackTrace();throw new RuntimeException(上传文件失败);}}/*** 删除文件* param pathUrl 文件全路径*/Overridepublic void delete(String pathUrl) {String key pathUrl.replace(minIOConfigProperties.getEndpoint()/,);int index key.indexOf(separator);String bucket key.substring(0,index);String filePath key.substring(index1);// 删除ObjectsRemoveObjectArgs removeObjectArgs RemoveObjectArgs.builder().bucket(bucket).object(filePath).build();try {minioClient.removeObject(removeObjectArgs);} catch (Exception e) {log.error(minio remove file error. pathUrl:{},pathUrl);e.printStackTrace();}}/*** 下载文件* param pathUrl 文件全路径* return 文件流**/Overridepublic byte[] downLoadFile(String pathUrl) {String key pathUrl.replace(minIOConfigProperties.getEndpoint()/,);int index key.indexOf(separator);String bucket key.substring(0,index);String filePath key.substring(index1);InputStream inputStream null;try {inputStream minioClient.getObject(GetObjectArgs.builder().bucket(minIOConfigProperties.getBucket()).object(filePath).build());} catch (Exception e) {log.error(minio down file error. pathUrl:{},pathUrl);e.printStackTrace();}ByteArrayOutputStream byteArrayOutputStream new ByteArrayOutputStream();byte[] buff new byte[100];int rc 0;while (true) {try {if (!((rc inputStream.read(buff, 0, 100)) 0)) break;} catch (IOException e) {e.printStackTrace();}byteArrayOutputStream.write(buff, 0, rc);}return byteArrayOutputStream.toByteArray();} }启动类 SpringBootApplicationComponentScan(basePackages {com.ma.config, com.ma.service}) public class SpringBootTest01Application {public static void main(String[] args) {SpringApplication.run(SpringBootTest01Application.class, args);} } 测试类 图片 package com.ma.springboottest01;import com.ma.service.FileStorageService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;import java.io.FileInputStream; import java.io.InputStream;SpringBootTest class SpringBootTest01ApplicationTests {Autowiredprivate FileStorageService fileStorageService;Testvoid contextLoads() {// 示例用法try {// 创建一个InputStream例如从本地文件获取InputStream fileInputStream new FileInputStream(D:\\Image\\星空.jpg);// 调用uploadImgFile方法进行文件上传String prefix user_images/; // 设置文件前缀String filename unique_image_name.jpg; // 设置文件名 // String url uploadImgFile(prefix, filename, fileInputStream);// url现在包含了上传文件的访问路径String url fileStorageService.uploadImgFile(prefix, filename, fileInputStream);System.out.println(File uploaded successfully. URL: url);} catch (Exception e) {// 处理上传失败的情况e.printStackTrace();}} }视频 package com.ma.springboottest01;import com.ma.service.FileStorageService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;import java.io.FileInputStream; import java.io.InputStream;SpringBootTest class SpringBootTest01ApplicationTests {Autowiredprivate FileStorageService fileStorageService;Testvoid contextLoads() {// 示例用法try {// 创建一个InputStream例如从本地文件获取 // InputStream fileInputStream new FileInputStream(D:\\Image\\星空.jpg);InputStream fileInputStream new FileInputStream(D:\\video\\test.mp4);// 调用uploadImgFile方法进行文件上传// 设置文件前缀和文件名String prefix videos/;String filename example_video.mp4; // String url uploadImgFile(prefix, filename, fileInputStream);// url现在包含了上传文件的访问路径String url fileStorageService.uploadImgFile(prefix, filename, fileInputStream);System.out.println(File uploaded successfully. URL: url);} catch (Exception e) {// 处理上传失败的情况e.printStackTrace();}} }删除minio服务器的文件 Testvoid t2(){fileStorageService.delete(http://192.168.74.128:9000/leadnews/videos//2023/11/27/example_video.mp4);} 下载minio服务器的文件 Testvoid t2() {byte[] bytes fileStorageService.downLoadFile(http://192.168.74.128:9000/leadnews/user_images//2023/11/27/unique_image_name.jpg);// 保存到本地文件的示例String localFilePath E:guo.jpg//; // 替换为实际的本地文件路径saveToFile(bytes, localFilePath);}public static void saveToFile(byte[] fileContent, String localFilePath) {try (FileOutputStream fos new FileOutputStream(localFilePath)) {fos.write(fileContent);System.out.println(File saved locally: localFilePath);} catch (IOException e) {e.printStackTrace();}}
http://www.pierceye.com/news/379748/

相关文章:

  • vs2015做的网站广东省白云区属于哪个市
  • 微信群投票网站怎么做佳木斯做网站公司
  • 建设网站用哪个主机好阳西哪里有做网站
  • 沈阳市有做网站的公司中文企业网站html模板
  • 破解织梦做的网站有什么页游传奇平台好
  • 临安网站开发网站建设做什么费用
  • 辽宁建设工程信息网网站python 网站开发
  • 企业网站.net免费做ppt的网站
  • 浦城 做网站wordpress下载页面
  • 广西住房城乡建设部网站网站优化怎么看
  • 网站建设负责人证明网络营销的10个特点
  • 泉州市服务好的网站设计塘沽网吧开门了吗
  • 商城网站建设哪家公司好wordpress输出到模板
  • 建站报价网站建设培训学校
  • 杭州高端网站定制手机网站开发应注意
  • 深圳网站建设选云聚达做二手元器件那个网站查价格
  • 网站建设公司企业模板微网站开发制作
  • 北京网站制作计划合理的网站结构
  • 网站建设如何搭建框架兰州seo排名
  • 网站作为医院形象建设cms搭建网站
  • 如何做个购物网站网站开发好不好
  • wordpress国内打开速度慢东莞搜索seo关键词
  • 鹿泉建设网站广安市建设局官方网站
  • 用花生棒自己做网站如何看网站的浏览量
  • 大连网站排名电商线上培训
  • 做金融网站做简历的网站
  • 求网站建设合伙人wordpress子页面怎么修改密码
  • 怎样登录建设互联网站厦门海绵城市建设官方网站
  • 网站怎么做权重互联网平台推广怎么做
  • 网站建设如果登录失败男生和男生做污的视频网站