|
| 1 | +package org.develnext.jphp.ext.httpserver.classes; |
| 2 | + |
| 3 | +import org.apache.commons.io.IOUtils; |
| 4 | +import org.develnext.jphp.ext.httpserver.HttpServerExtension; |
| 5 | +import php.runtime.annotation.Reflection; |
| 6 | +import php.runtime.env.Environment; |
| 7 | +import php.runtime.ext.core.classes.stream.DataStream; |
| 8 | +import php.runtime.ext.core.classes.stream.MemoryStream; |
| 9 | +import php.runtime.ext.core.classes.stream.ResourceStream; |
| 10 | +import php.runtime.lang.BaseWrapper; |
| 11 | +import php.runtime.reflection.ClassEntity; |
| 12 | + |
| 13 | +import javax.servlet.http.Part; |
| 14 | +import java.io.ByteArrayInputStream; |
| 15 | +import java.io.IOException; |
| 16 | + |
| 17 | +@Reflection.Name("HttpPart") |
| 18 | +@Reflection.Namespace(HttpServerExtension.NS) |
| 19 | +public class PHttpPart extends BaseWrapper<Part> { |
| 20 | + public PHttpPart(Environment env, Part wrappedObject) { |
| 21 | + super(env, wrappedObject); |
| 22 | + } |
| 23 | + |
| 24 | + public PHttpPart(Environment env, ClassEntity clazz) { |
| 25 | + super(env, clazz); |
| 26 | + } |
| 27 | + |
| 28 | + @Reflection.Signature |
| 29 | + public byte[] readAll() throws IOException { |
| 30 | + ByteArrayInputStream inputStream = (ByteArrayInputStream) getWrappedObject().getInputStream(); |
| 31 | + return inputStream.readAllBytes(); |
| 32 | + } |
| 33 | + |
| 34 | + @Reflection.Signature |
| 35 | + public String getName() { |
| 36 | + return getWrappedObject().getName(); |
| 37 | + } |
| 38 | + |
| 39 | + @Reflection.Signature |
| 40 | + public String getContentType() { |
| 41 | + return getWrappedObject().getContentType(); |
| 42 | + } |
| 43 | + |
| 44 | + @Reflection.Signature |
| 45 | + public String getSubmittedFileName() { |
| 46 | + return getWrappedObject().getSubmittedFileName(); |
| 47 | + } |
| 48 | + |
| 49 | + @Reflection.Signature |
| 50 | + public long getSize() { |
| 51 | + return getWrappedObject().getSize(); |
| 52 | + } |
| 53 | +} |
0 commit comments