Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
F
fileCenter
概览
Overview
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
李东旭
fileCenter
Commits
3fdce195
提交
3fdce195
authored
2月 28, 2023
作者:
passer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
文件服务器下载共享文件接口
父级
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
253 行增加
和
0 行删除
+253
-0
pom.xml
+46
-0
src/main/java/com/file/center/FileCenterApplication.java
+13
-0
src/main/java/com/file/center/controller/OCRToolController.java
+26
-0
src/main/java/com/file/center/util/CopyImageDTO.java
+51
-0
src/main/java/com/file/center/util/ImageUtils.java
+62
-0
src/main/java/com/file/center/util/OCRAPI.java
+27
-0
src/main/resources/application.yml
+28
-0
没有找到文件。
pom.xml
0 → 100644
查看文件 @
3fdce195
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.7.9
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.file
</groupId>
<artifactId>
fileCenter
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
fileCenter
</name>
<description>
file controller
</description>
<properties>
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
src/main/java/com/file/center/FileCenterApplication.java
0 → 100644
查看文件 @
3fdce195
package
com
.
file
.
center
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
FileCenterApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
FileCenterApplication
.
class
,
args
);
}
}
src/main/java/com/file/center/controller/OCRToolController.java
0 → 100644
查看文件 @
3fdce195
package
com
.
file
.
center
.
controller
;
import
com.file.center.util.CopyImageDTO
;
import
com.file.center.util.ImageUtils
;
import
com.file.center.util.OCRAPI
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 说明:
*
* @author Li
*/
@RequestMapping
(
"/OCRTool"
)
@RestController
public
class
OCRToolController
{
@PostMapping
(
"/copyImage"
)
public
String
copyImage
(
@RequestBody
CopyImageDTO
dto
)
throws
Exception
{
return
ImageUtils
.
downloadByURL
(
dto
.
getUrlString
(),
dto
.
getFileName
(),
OCRAPI
.
getImagePre
(),
dto
.
getLinux
());
}
}
src/main/java/com/file/center/util/CopyImageDTO.java
0 → 100644
查看文件 @
3fdce195
package
com
.
file
.
center
.
util
;
/**
* @author:Li
* @create: 2022-12-23 16:02
* @Description:
*/
public
class
CopyImageDTO
{
private
String
urlString
;
private
String
fileName
;
private
Boolean
isLinux
;
private
String
savePath
=
OCRAPI
.
getImagePre
();
public
String
getUrlString
()
{
return
urlString
;
}
public
void
setUrlString
(
String
urlString
)
{
this
.
urlString
=
urlString
;
}
public
String
getFileName
()
{
return
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
Boolean
getLinux
()
{
return
isLinux
;
}
public
void
setLinux
(
Boolean
linux
)
{
isLinux
=
linux
;
}
public
String
getSavePath
()
{
return
savePath
;
}
public
void
setSavePath
(
String
savePath
)
{
this
.
savePath
=
savePath
;
}
}
src/main/java/com/file/center/util/ImageUtils.java
0 → 100644
查看文件 @
3fdce195
package
com
.
file
.
center
.
util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.URL
;
import
java.net.URLConnection
;
/**
* 图片处理工具类
*
* @author Li
*/
public
class
ImageUtils
{
/**
* 根据图片的URL从网页下载图片
*
* @param urlString 图片URL地址
* @param filename 下载后的图片名称
* @param savePath 保存路径
* @throws Exception
*/
public
static
String
downloadByURL
(
String
urlString
,
String
filename
,
String
savePath
,
Boolean
isLinux
)
throws
Exception
{
String
FileSeparator
=
"\\"
;
if
(
isLinux
)
{
FileSeparator
=
"/"
;
}
// 构造URL
URL
url
=
new
URL
(
urlString
);
// 打开连接
URLConnection
con
=
url
.
openConnection
();
// 设置请求超时为5s
con
.
setConnectTimeout
(
5
*
1000
);
// 输入流
InputStream
is
=
con
.
getInputStream
();
// 1K的数据缓冲
byte
[]
bs
=
new
byte
[
1024
];
// 读取到的数据长度
int
len
;
// 输出的文件流
File
sf
=
new
File
(
savePath
);
if
(!
sf
.
exists
())
{
sf
.
mkdirs
();
}
OutputStream
os
=
new
FileOutputStream
(
sf
.
getPath
()
+
FileSeparator
+
"part"
+
FileSeparator
+
filename
);
// 开始读取
while
((
len
=
is
.
read
(
bs
))
!=
-
1
)
{
os
.
write
(
bs
,
0
,
len
);
}
// 完毕,关闭所有链接
os
.
close
();
is
.
close
();
return
savePath
+
FileSeparator
+
"part"
+
FileSeparator
+
filename
;
}
}
src/main/java/com/file/center/util/OCRAPI.java
0 → 100644
查看文件 @
3fdce195
package
com
.
file
.
center
.
util
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
* 说明:
*
* @author Li
*/
@Component
public
class
OCRAPI
{
private
static
String
imagePre
;
public
static
String
getImagePre
()
{
return
imagePre
;
}
@Value
(
"${ruoyi.profile}"
)
public
void
setImagePre
(
String
imagePre
)
{
OCRAPI
.
imagePre
=
imagePre
;
}
}
src/main/resources/application.yml
0 → 100644
查看文件 @
3fdce195
# ??????
ruoyi
:
# ??
name
:
ocr_son_server
# ??
version
:
3.3.0
# ????
copyrightYear
:
2021
# ??????
demoEnabled
:
true
# ???? ??? Windows??D:/ruoyi/uploadPath?Linux?? /home/ruoyi/uploadPath?
profile
:
/mydata/server/ocrfile
# ??????
server
:
# ????HTTP??????8080
port
:
8188
servlet
:
# ???????
context-path
:
/api
tomcat
:
# tomcat?URI??
uri-encoding
:
UTF-8
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论