本文整理汇总了Java中io.netty.handler.codec.http.multipart.InterfaceHttpData.release方法的典型用法代码示例。如果您正苦于以下问题:Java InterfaceHttpData.release方法的具体用法?Java InterfaceHttpData.release怎么用?Java InterfaceHttpData.release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.multipart.InterfaceHttpData
的用法示例。
在下文中一共展示了InterfaceHttpData.release方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parsePostParam
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private void parsePostParam(InterfaceHttpData data) {
try {
switch (data.getHttpDataType()) {
case Attribute:
Attribute param = (Attribute) data;
this.paramsMap.put(param.getName(), Collections.singletonList(param.getValue()));
break;
default:
break;
}
} catch (IOException e) {
e.printStackTrace();
}finally {
data.release();
}
}
示例2: handleUploadMessage
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private void handleUploadMessage(HttpMessage httpMsg, Message uploadMessage) throws IOException{
if (httpMsg instanceof HttpContent) {
HttpContent chunk = (HttpContent) httpMsg;
decoder.offer(chunk);
try {
while (decoder.hasNext()) {
InterfaceHttpData data = decoder.next();
if (data != null) {
try {
handleUploadFile(data, uploadMessage);
} finally {
data.release();
}
}
}
} catch (EndOfDataDecoderException e1) {
//ignore
}
if (chunk instanceof LastHttpContent) {
resetUpload();
}
}
}
示例3: readHttpDataChunkByChunk
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private void readHttpDataChunkByChunk() throws IOException
{
while (decoder.hasNext())
{
InterfaceHttpData data = decoder.next();
if (data != null)
{
try
{
// new value
writeHttpData(data);
}
finally
{
data.release();
}
}
}
}
示例4: readHttpDataChunkByChunk
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
/**
* Example of reading request by chunk and getting values from chunk to chunk
*/
private void readHttpDataChunkByChunk() {
try {
while (decoder.hasNext()) {
InterfaceHttpData data = decoder.next();
if (data != null) {
try {
// new value
writeHttpData(data);
} finally {
data.release();
}
}
}
} catch (EndOfDataDecoderException e1) {
// end
responseContent.append("\r\n\r\nEND OF CONTENT CHUNK BY CHUNK\r\n\r\n");
}
}
示例5: readHttpDataChunkByChunk
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private void readHttpDataChunkByChunk() {
int chunk=0;
String checksum="";
int sum=0;
try {
while (decoder.hasNext()) {
InterfaceHttpData data = decoder.next();
if (data != null) {
try {
writeHttpData(data,chunk,checksum,sum);
} finally {
data.release();
}
}
}
} catch (EndOfDataDecoderException e1) {
return;
}
}
示例6: readFileUploadData
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private HttpResponseStatus readFileUploadData() throws IOException {
while (decoder.hasNext()) {
final InterfaceHttpData data = decoder.next();
if (data != null) {
try {
logger.info("BODY FileUpload: " + data.getHttpDataType().name() + ": " + data);
if (data.getHttpDataType() == HttpDataType.FileUpload) {
final FileUpload fileUpload = (FileUpload) data;
if (fileUpload.isCompleted()) {
requestProcessed = true;
final String format = ImageStoreUtil.checkTemplateFormat(fileUpload.getFile().getAbsolutePath(), fileUpload.getFilename());
if (StringUtils.isNotBlank(format)) {
final String errorString = "File type mismatch between the sent file and the actual content. Received: " + format;
logger.error(errorString);
responseContent.append(errorString);
storageResource.updateStateMapWithError(uuid, errorString);
return HttpResponseStatus.BAD_REQUEST;
}
final String status = storageResource.postUpload(uuid, fileUpload.getFile().getName());
if (status != null) {
responseContent.append(status);
storageResource.updateStateMapWithError(uuid, status);
return HttpResponseStatus.INTERNAL_SERVER_ERROR;
} else {
responseContent.append("upload successful.");
return HttpResponseStatus.OK;
}
}
}
} finally {
data.release();
}
}
}
responseContent.append("received entity is not a file");
return HttpResponseStatus.UNPROCESSABLE_ENTITY;
}
示例7: finishUpload
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private String finishUpload() throws Exception {
String pathTo = null;
try {
while (decoder.hasNext()) {
InterfaceHttpData data = decoder.next();
if (data != null) {
if (data instanceof DiskFileUpload) {
DiskFileUpload diskFileUpload = (DiskFileUpload) data;
Path tmpFile = diskFileUpload.getFile().toPath();
String uploadedFilename = diskFileUpload.getFilename();
String extension = "";
if (uploadedFilename.contains(".")) {
extension = uploadedFilename.substring(uploadedFilename.lastIndexOf("."),
uploadedFilename.length());
}
String finalName = tmpFile.getFileName().toString() + extension;
//this is just to make it work on team city.
Path staticPath = Paths.get(staticFolderPath, uploadFolder);
if (!Files.exists(staticPath)) {
Files.createDirectories(staticPath);
}
Files.move(tmpFile, Paths.get(staticFolderPath, uploadFolder, finalName),
StandardCopyOption.REPLACE_EXISTING);
pathTo = uploadFolder + finalName;
}
data.release();
}
}
} catch (EndOfDataDecoderException endOfData) {
//ignore. that's fine.
} finally {
// destroy the decoder to release all resources
decoder.destroy();
decoder = null;
}
return pathTo;
}
示例8: readFileUploadData
import io.netty.handler.codec.http.multipart.InterfaceHttpData; //导入方法依赖的package包/类
private HttpResponseStatus readFileUploadData() throws IOException {
while (decoder.hasNext()) {
InterfaceHttpData data = decoder.next();
if (data != null) {
try {
logger.info("BODY FileUpload: " + data.getHttpDataType().name() + ": " + data);
if (data.getHttpDataType() == HttpDataType.FileUpload) {
FileUpload fileUpload = (FileUpload) data;
if (fileUpload.isCompleted()) {
requestProcessed = true;
String format = ImageStoreUtil.checkTemplateFormat(fileUpload.getFile().getAbsolutePath(), fileUpload.getFilename());
if(StringUtils.isNotBlank(format)) {
String errorString = "File type mismatch between the sent file and the actual content. Received: " + format;
logger.error(errorString);
responseContent.append(errorString);
storageResource.updateStateMapWithError(uuid, errorString);
return HttpResponseStatus.BAD_REQUEST;
}
String status = storageResource.postUpload(uuid, fileUpload.getFile().getName());
if (status != null) {
responseContent.append(status);
storageResource.updateStateMapWithError(uuid, status);
return HttpResponseStatus.INTERNAL_SERVER_ERROR;
} else {
responseContent.append("upload successful.");
return HttpResponseStatus.OK;
}
}
}
} finally {
data.release();
}
}
}
responseContent.append("received entity is not a file");
return HttpResponseStatus.UNPROCESSABLE_ENTITY;
}