Search in sources :

Example 1 with MultipartStream

use of org.apache.commons.fileupload.MultipartStream in project Lucee by lucee.

the class MultiPartResponseUtils method getParts.

public static Array getParts(byte[] barr, String contentTypeHeader) throws IOException, PageException {
    String boundary = extractBoundary(contentTypeHeader, "");
    ByteArrayInputStream bis = new ByteArrayInputStream(barr);
    MultipartStream stream;
    Array result = new ArrayImpl();
    // 
    stream = new MultipartStream(bis, getBytes(boundary, "UTF-8"));
    boolean hasNextPart = stream.skipPreamble();
    while (hasNextPart) {
        result.append(getPartData(stream));
        hasNextPart = stream.readBoundary();
    }
    return result;
}
Also used : Array(lucee.runtime.type.Array) ByteArrayInputStream(java.io.ByteArrayInputStream) ArrayImpl(lucee.runtime.type.ArrayImpl) MultipartStream(org.apache.commons.fileupload.MultipartStream)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 Array (lucee.runtime.type.Array)1 ArrayImpl (lucee.runtime.type.ArrayImpl)1 MultipartStream (org.apache.commons.fileupload.MultipartStream)1