Revision 8748
Added by ben leinfelder almost 10 years ago
MetacatUtil.java | ||
---|---|---|
30 | 30 |
import java.io.FileInputStream; |
31 | 31 |
import java.io.FileOutputStream; |
32 | 32 |
import java.io.IOException; |
33 |
import java.io.InputStream; |
|
33 | 34 |
import java.io.PrintWriter; |
34 | 35 |
import java.net.MalformedURLException; |
35 | 36 |
import java.util.Hashtable; |
36 | 37 |
import java.util.Vector; |
37 | 38 |
|
39 |
import org.apache.commons.fileupload.FileItem; |
|
40 |
import org.apache.commons.io.IOUtils; |
|
38 | 41 |
import org.apache.log4j.Logger; |
39 | 42 |
|
40 | 43 |
import com.oreilly.servlet.multipart.FilePart; |
... | ... | |
400 | 403 |
* the name of the file to be written to disk |
401 | 404 |
* @return tempFilePath a String containing location of temporary file |
402 | 405 |
*/ |
403 |
public static File writeTempUploadFile (FilePart filePart, String fileName) throws IOException {
|
|
406 |
public static File writeTempUploadFile (FileItem fi, String fileName) throws Exception {
|
|
404 | 407 |
File tempFile = null; |
405 | 408 |
String tempDirPath = null; |
406 | 409 |
try { |
... | ... | |
441 | 444 |
|
442 | 445 |
//tempFile = new File(tempDirPath, fileName); |
443 | 446 |
tempFile = File.createTempFile("upload", ".tmp", tempDir); |
444 |
fileSize = filePart.writeTo(tempFile); |
|
447 |
fi.write(tempFile); |
|
448 |
fileSize = fi.getSize(); |
|
445 | 449 |
|
446 | 450 |
if (fileSize == 0) { |
447 | 451 |
logMetacat.warn("Uploaded file '" + fileName + "'is empty!"); |
Also available in: Unified diff
switch to use FIleUpload instead of O'Reilly COS library for handling chunked file uploads. https://projects.ecoinformatics.org/ecoinfo/issues/6517