Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oscar Enrique Gonzalez Escurra
th-app-java
Commits
fb0a519a
Commit
fb0a519a
authored
Oct 19, 2023
by
Amparo Oliver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prueba Images path
parent
6b5090bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar
+0
-0
curriculumsearch/src/main/java/com/roshka/controller/BirthdayController.java
+25
-1
curriculumsearch/src/main/webapp/jsp/birthday-form.jsp
+1
-1
No files found.
curriculumsearch/curriculumsearch-0.0.1-SNAPSHOT.jar
View file @
fb0a519a
No preview for this file type
curriculumsearch/src/main/java/com/roshka/controller/BirthdayController.java
View file @
fb0a519a
...
...
@@ -84,6 +84,28 @@ public class BirthdayController {
throw
new
RuntimeException
(
e
);
}
if
(!
file
.
isEmpty
())
{
String
originalFilename
=
file
.
getOriginalFilename
();
String
fileExtension
=
originalFilename
.
substring
(
originalFilename
.
lastIndexOf
(
"."
)
+
1
).
toLowerCase
();
// Verifica que el archivo sea jpg o png
if
(
fileExtension
.
equals
(
"jpg"
)
||
fileExtension
.
equals
(
"png"
))
{
Path
directorioImagenes
=
Paths
.
get
(
"uploadsBirthday/"
+
DigestUtils
.
md5Hex
(
originalFilename
)
+
"."
+
fileExtension
);
String
rutaAbsoluta
=
directorioImagenes
.
toFile
().
getAbsolutePath
();
try
{
byte
[]
bytesImg
=
file
.
getBytes
();
Path
rutaCompleta
=
Paths
.
get
(
rutaAbsoluta
);
Files
.
write
(
rutaCompleta
,
bytesImg
);
// Si todo sale bien, guarda la foto en la base de datos
birthday
.
setFoto
(
"http://192.168.16.90:8888/uploadsBirthday/"
+
DigestUtils
.
md5Hex
(
originalFilename
)
+
"."
+
fileExtension
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
else
{
// Maneja el caso en que el formato del archivo no sea jpg o png
model
.
addAttribute
(
"errorFormato"
,
true
);
return
"birthday-form"
;
}
/*
Path directorioImagenes= Paths.get("images/"+ DigestUtils.md5Hex(file.getOriginalFilename()) + ".jpg");
String rutaAbsoluta = directorioImagenes.toFile().getAbsolutePath();
try {
...
...
@@ -91,10 +113,12 @@ public class BirthdayController {
Path rutaCompleta=Paths.get(rutaAbsoluta);
Files.write(rutaCompleta, bytesImg);
// si todo salio bien guardamos la foto en la base de datos
birthday
.
setFoto
(
"http://
localhost:8080
/images/"
+
DigestUtils
.
md5Hex
(
file
.
getOriginalFilename
())
+
".jpg"
);
birthday.setFoto("http://
192.168.16.90:8888
/images/"+ DigestUtils.md5Hex(file.getOriginalFilename()) + ".jpg");
} catch (IOException e) {
throw new RuntimeException(e);
}
*/
}
if
(
id
!=
null
)
birthday
.
setId
(
id
);
birthdayRepository
.
save
(
birthday
);
...
...
curriculumsearch/src/main/webapp/jsp/birthday-form.jsp
View file @
fb0a519a
...
...
@@ -7,7 +7,7 @@
<layout:put block="contents" type="REPLACE">
<div class="card justify-content-center mx-auto mt-2" style="width: 20rem;">
<div class="card-header">
<h5>Cumpleaño</h5>
<h5>Cumpleaño
s
</h5>
</div>
<form:form
action="/cumples/${cumple.id == null ? 'agregar' : 'modificar/'.concat(cumple.id)}"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment