|
@@ -4,6 +4,7 @@ import com.aliyun.oss.OSS;
|
|
|
import com.aliyun.oss.OSSClientBuilder;
|
|
import com.aliyun.oss.OSSClientBuilder;
|
|
|
import com.poteviohealth.cgp.common.model.VaultsResponse;
|
|
import com.poteviohealth.cgp.common.model.VaultsResponse;
|
|
|
import com.poteviohealth.cgp.common.utils.CgpTool;
|
|
import com.poteviohealth.cgp.common.utils.CgpTool;
|
|
|
|
|
+import com.poteviohealth.cgp.common.utils.ImageUtils;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -159,4 +160,28 @@ public class OssUtils {
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取文件
|
|
|
|
|
+ * @param fileUrl
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public InputStream getFile(String fileUrl) {
|
|
|
|
|
+
|
|
|
|
|
+ // 创建OSSClient实例。
|
|
|
|
|
+ OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, secretAccessKey);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ InputStream inputStream = ossClient.getObject(bucketName, "yqaa/2412/S256337789353984N-B20D9D3E-B0A5-4EE1-8F95-7CBE6AFDBED2.jpeg").getObjectContent();
|
|
|
|
|
+ log.info(ImageUtils.readImagePix(inputStream));
|
|
|
|
|
+ return inputStream;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return null;
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ if (ossClient != null) {
|
|
|
|
|
+ ossClient.shutdown();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|