packagecom.zhong.utils;importcom.aliyun.oss.ClientException;importcom.aliyun.oss.OSS;importcom.aliyun.oss.OSSClientBuilder;importcom.aliyun.oss.OSSException;importcom.aliyun.oss.model.PutObjectRequest;importcom.aliyun.oss.model.PutObjectResult;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.stereotype.Component;importjava.io.InputStream;/*** @ClassName : AliOssUtil* @Description : 阿里云上传服务* @Author : zhx* @Date: 2024-03-1 20:29*/@ComponentpublicclassAliOssUtil{// 抽取配置privatestaticStringENDPOINT;@Value("${alioss.endpoint}")publicvoidsetENDPOINT(String endpoint){ENDPOINT= endpoint;}privatestaticStringACCESS_KEY;@Value("${alioss.access_key}")publicvoidsetAccessKey(String accessKey){ACCESS_KEY= accessKey;}privatestaticStringACCESS_KEY_SECRET;@Value("${alioss.access_key_secret}")publicvoidsetAccessKeySecret(String accessKeySecret){ACCESS_KEY_SECRET= accessKeySecret;}privatestaticStringBUCKETNAME;@Value("${alioss.bucketName}")publicvoidsetBUCKETNAME(String bucketName){BUCKETNAME= bucketName;}// 上传业务publicstaticStringuploadFile(String objectName,InputStream inputStream){String url ="";// 创建OSSClient实例。OSS ossClient =newOSSClientBuilder().build(ENDPOINT,ACCESS_KEY,ACCESS_KEY_SECRET);try{// 创建PutObjectRequest对象。PutObjectRequest putObjectRequest =newPutObjectRequest(BUCKETNAME, objectName, inputStream);// 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。// ObjectMetadata metadata = new ObjectMetadata();// metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());// metadata.setObjectAcl(CannedAccessControlList.Private);// putObjectRequest.setMetadata(metadata);// 上传文件。PutObjectResult result = ossClient.putObject(putObjectRequest);url ="https://"+BUCKETNAME+"."+ENDPOINT.substring(ENDPOINT.lastIndexOf("/")+1)+"/"+ objectName;}catch(OSSException oe){System.out.println("Caught an OSSException, which means your request made it to OSS, "+"but was rejected with an error response for some reason.");System.out.println("Error Message:"+ oe.getErrorMessage());System.out.println("Error Code:"+ oe.getErrorCode());System.out.println("Request ID:"+ oe.getRequestId());System.out.println("Host ID:"+ oe.getHostId());}catch(ClientException ce){System.out.println("Caught an ClientException, which means the client encountered "+"a serious internal problem while trying to communicate with OSS, "+"such as not being able to access the network.");System.out.println("Error Message:"+ ce.getMessage());}finally{if(ossClient !=null){ossClient.shutdown();}}return url;}}
一、朴素二分
. - 力扣(LeetCode). - 备战技术面试?力扣提供海量技术面试资源,帮助你高效提升编程技能,轻松拿下世界 IT 名企 Dream Offer。https://leetcode.cn/problems/binary-search/description/ int left 0, right nums.…
一、何为GC
数据是存储在内存中的,而内存又分为Stack栈内存和Heap堆内存
Stack栈内存Heap堆内存速度快、效率高结构复杂类型、大小有限制对象只能保存简单的数据引用数据类型基础数据类型、值类型-
举个例子
var c new Customer{id: 123,name: "Jack"…