Created
January 31, 2013 17:23
-
-
Save Isxida/4684549 to your computer and use it in GitHub Desktop.
How to upload a file en cualquier lado! :DDDD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void registrarSolicitud(File doc, SolicitudDTO sol) throws Exception { | |
System.out.println(doc.getAbsoluteFile()); | |
Date dFecha = new Date(); | |
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yy_HH_mm"); | |
Map<String, Object> session = ActionContext.getContext().getSession(); | |
// usuario que esta en sesion (jefe de area que registra la solicitud) | |
UsuarioDTO usu = (UsuarioDTO) session.get("s_usuario"); | |
// la ruta | |
String url = "C:\\TEMP\\SRQ_" + sdf1.format(dFecha) + ".pdf"; | |
// seteo de campos q faltan para el bean SOLICITUD | |
sol.setUrlSol(url); | |
// area | |
int area = this.getAreaUsu(usu.getIdUsu()); | |
AreaDTO areaBean = new AreaDTO(); | |
areaBean.setIdArea(area); | |
sol.setArea(areaBean); | |
// id usuario | |
sol.setIdUsu(usu.getIdUsu()); | |
// fecha de registro | |
sol.setFecRegSol(dFecha); | |
// escribe el archivo en el disco | |
File archivo = new File(url); | |
FileUtils.copyFile(doc, archivo); | |
// registro en la bd | |
SqlSession sqlSession = SessionFactory.getSqlSessionFactory() | |
.openSession(); | |
solicitudDAO.registrarSolicitud(sqlSession, sol); | |
sqlSession.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment