| | |
| | | |
| | | |
| | | protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest fullRequest) throws Exception { |
| | | System.err.println("fullRequest:::"+fullRequest); |
| | | boolean isRequestValid = isValidHttpRequest(ctx, fullRequest); |
| | | if (!isRequestValid) { |
| | | log.warn("Discard invalid request."); |
| | | |
| | | //HttpResponseUtils.sendResponseJson(ctx, HttpResponseStatus.BAD_REQUEST, "验证失败"); |
| | | return; |
| | | } |
| | | |
| | |
| | | // file.write(ByteBufUtil.getBytes(fullRequest.content())); |
| | | // file.close(); |
| | | |
| | | String fileName = this.parseFileName(fullRequest); |
| | | //String fileName = this.parseFileName(fullRequest); |
| | | |
| | | |
| | | String fileName = System.currentTimeMillis() + ".jpg"; |
| | | |
| | | ByteArrayInputStream stream = new ByteArrayInputStream(ByteBufUtil.getBytes(fullRequest.content())); |
| | | MockMultipartFile multipartFile |
| | |
| | | |
| | | |
| | | // 上传荆楚水库的文件地址 |
| | | System.err.println("iOssClient::"); |
| | | System.err.println(iOssClient.getClass().getName()); |
| | | System.err.println(iOssClient); |
| | | // System.err.println("iOssClient::"); |
| | | // System.err.println(iOssClient.getClass().getName()); |
| | | // System.err.println(iOssClient); |
| | | |
| | | String picurl = iOssClient.uploadFile(fileName, multipartFile); |
| | | System.err.println("最终地址"+picurl); |
| | | // System.err.println("图片上传地址"+picurl); |
| | | log.info("图片上传地址::"+picurl); |
| | | |
| | | // 请求参数放入实体中 |
| | | BaiyiPicEntity baiyiPicEntity = parseEntity(fullRequest); |
| | |
| | | try { |
| | | URI uri = UriUtils.getURI(request); |
| | | log.info(uri.getPath()); |
| | | |
| | | // 密码校验 |
| | | boolean authFlag = auth(ctx, uri); |
| | | if (!authFlag) { |
| | | // 校验不通过 |
| | | // authorization效验 |
| | | String authorization = request.headers().get("Authorization"); |
| | | if(!this.nettyHttpConfig.getAuthorization().equals(authorization)) { |
| | | log.warn("Authorization校验失败!!"); |
| | | // 校验不通过 |
| | | HttpResponseUtils.sendResponseJson(ctx, HttpResponseStatus.UNAUTHORIZED, HttpResponseStatus.UNAUTHORIZED.toString()); |
| | | // 校验不通过 |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // 密码校验 |
| | | // boolean authFlag = auth(ctx, uri); |
| | | // if (!authFlag) { |
| | | // // 校验不通过 |
| | | // HttpResponseUtils.sendResponseJson(ctx, HttpResponseStatus.UNAUTHORIZED, HttpResponseStatus.UNAUTHORIZED.toString()); |
| | | // // 校验不通过 |
| | | // return false; |
| | | // } |
| | | |
| | | // uri 路径校验 |
| | | if (!uri.getPath().startsWith(UPLOAD_FILE_URL)) { |
| | | HttpResponseUtils.sendResponseJson(ctx, HttpResponseStatus.BAD_REQUEST,"the url must starts with /postfile"); |
| | | return false; |
| | | } |
| | | // if (!uri.getPath().startsWith(UPLOAD_FILE_URL)) { |
| | | // HttpResponseUtils.sendResponseJson(ctx, HttpResponseStatus.BAD_REQUEST,"the url must starts with /postfile"); |
| | | // return false; |
| | | // } |
| | | |
| | | return true; |
| | | } catch (Exception exception) { |