当前位置: 首页>>代码示例>>Java>>正文


Java InterfaceHttpData.release方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:togethwy,项目名称:kurdran,代码行数:17,代码来源:HttpRequest.java

示例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();
           }
       }
}
 
开发者ID:rushmore,项目名称:zbus,代码行数:25,代码来源:MessageCodec.java

示例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();
            }
        }
    }
}
 
开发者ID:touwolf,项目名称:bridje-framework,代码行数:20,代码来源:HttpServerChannelHandler.java

示例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");
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:22,代码来源:HttpUploadServerHandler.java

示例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;
    } 
}
 
开发者ID:desperado1992,项目名称:distributeTemplate,代码行数:21,代码来源:HttpUploadServerHandler.java

示例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;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:38,代码来源:HttpUploadServerHandler.java

示例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;
}
 
开发者ID:blynkkk,项目名称:blynk-server,代码行数:41,代码来源:UploadHandler.java

示例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;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:38,代码来源:HttpUploadServerHandler.java


注:本文中的io.netty.handler.codec.http.multipart.InterfaceHttpData.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。