All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.data.MemoryUpload Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package play.data;

import java.io.File;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.apache.commons.fileupload.FileItem;

public class MemoryUpload implements Upload {

    FileItem fileItem;

    public MemoryUpload(FileItem fileItem) {
        this.fileItem = fileItem;
    }

    public File asFile() {
        throw new UnsupportedOperationException();
    }
    
    public byte[] asBytes() {
        return fileItem.get();
    }

    public InputStream asStream() {
        return new ByteArrayInputStream(fileItem.get());
    }

    public String getContentType() {
        return fileItem.getContentType();
    }

    public String getFileName() {
        return fileItem.getName();
    }

    public String getFieldName() {
        return fileItem.getFieldName();
    }

    public Long getSize() {
        return fileItem.getSize();
    }
    
    public boolean isInMemory() {
        return fileItem.isInMemory();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy