| 1 | |
package org.webslinger.commons.fileupload; |
| 2 | |
|
| 3 | |
import java.io.File; |
| 4 | |
import java.io.InputStream; |
| 5 | |
import java.io.IOException; |
| 6 | |
import java.io.OutputStream; |
| 7 | |
import java.util.ArrayList; |
| 8 | |
import java.util.Enumeration; |
| 9 | |
import java.util.HashMap; |
| 10 | |
import java.util.List; |
| 11 | |
import java.util.Map; |
| 12 | |
import javax.servlet.http.HttpServletRequest; |
| 13 | |
|
| 14 | |
import org.apache.commons.fileupload.FileItem; |
| 15 | |
import org.apache.commons.fileupload.FileItemFactory; |
| 16 | |
import org.apache.commons.fileupload.FileUploadException; |
| 17 | |
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
| 18 | |
import org.apache.commons.fileupload.servlet.ServletFileUpload; |
| 19 | |
|
| 20 | |
import org.apache.commons.vfs.FileObject; |
| 21 | |
|
| 22 | |
import org.webslinger.commons.vfs.VFSUtil; |
| 23 | |
import org.webslinger.io.Charsets; |
| 24 | |
import org.webslinger.io.IOUtil; |
| 25 | |
|
| 26 | |
public class CommonsVfsFileItem extends AbstractCommonsVfsFileItem { |
| 27 | |
private final FileObject file; |
| 28 | |
|
| 29 | |
public CommonsVfsFileItem(String fileName, FileObject file) { |
| 30 | 0 | super(fileName); |
| 31 | 0 | this.file = file; |
| 32 | 0 | } |
| 33 | |
|
| 34 | |
public FileObject getFile() throws IOException { |
| 35 | 0 | return file; |
| 36 | |
} |
| 37 | |
|
| 38 | |
public synchronized void delete() { |
| 39 | 0 | } |
| 40 | |
|
| 41 | |
public String getContentType() { |
| 42 | |
try { |
| 43 | 0 | return getFile().getContent().getContentInfo().getContentType(); |
| 44 | 0 | } catch (Exception e) { |
| 45 | 0 | throw (InternalError) new InternalError(e.getMessage()).initCause(e); |
| 46 | |
} |
| 47 | |
} |
| 48 | |
} |