private void writeFormFile(FormFileField formFile) throws IOException {
File file = formFile.getFile();
// create inputstream
currentFileName = file.getName();
System.out.println("CURRENT FILE "+ currentFileName);
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
// write boundary
out.writeBytes(PREFIX);
out.writeBytes(boundary);
out.writeBytes(NEWLINE);
// write content header
out.writeBytes("Content-Disposition: form-data; name=\"" + formFile.getName() + "\"; filename=\"" + formFile.getURLEncodedUploadName() + "\"" + NEWLINE);
out.writeBytes("Content-Type: " + formFile.getContentType() + NEWLINE);
out.writeBytes(NEWLINE);
// write content
byte[] data = new byte[1024];
int len = 0;
while ((len = in.read(data, 0, data.length)) != -1) {
out.write(data, 0, len);
// update properties
bytesProcessed = bytesProcessed + len;
}
out.writeBytes(NEWLINE);
System.out.println("ANTES DEL FLUSH");
out.flush();
Comentarios recientes
hace 13 semanas 5 días
hace 1 año 25 semanas
hace 1 año 29 semanas
hace 1 año 37 semanas
hace 1 año 45 semanas
hace 1 año 47 semanas
hace 1 año 49 semanas
hace 2 años 2 días
hace 2 años 2 días
hace 2 años 6 semanas