发表于: 2017-11-11 23:39:50

1 924



今天完成的事情:

1. 完成代码的结构调整(出先很大错误)

2. spring+ zookeeper +RMI 并不能整合在一起 发现了新的方案: spring+ zookeeper +Dubbo(把RMI协议兼容了) 

3. byte[] 和 InputStream 相互转换

4. RMI上传大文件

5 .spring MVC的封装的上传文件的方式


明天计划的事情

1. spring+ zookeeper +Dubbo

2. 完结任务8


遇到的问题:

1. 用 rmi 进行文件上传的时候,从接口处穿的参数必须序列化,但是我文件上传的参数穿的是request,不能传输,解决办法是,写一个文件的model,通过传入文件的modle 序列化进行传入参数,但是这是错误的思路:师兄说service分离后只是针对数据库的操作,而图片上传的这种应放在WEB,而后的更新操作在用service .


收获:

1 .spring MVC的封装的上传文件的方式

@RequestParam(value = "myfile") MultipartFile  file 

这是springMVC封装好的myfile 为上传表单的name


2. byte[] 和 InputStream 相互转换(以前只是认为可以存入缓存,没想到还有这个用处)

把流转化为数组形式 (顺便存入缓存)
public static byte[] streamToByte(InputStream inStream) throws Exception{
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int len = -1;
    while((len = inStream.read(buffer)) != -1){
        outStream.write(buffer, 0, len);
    }
    outStream.close();
    inStream.close();
    return outStream.toByteArray();
}
2、将byte数组转换为InputStream:
byte[] byt = new byte[1024];
InputStream input = new ByteArrayInputStream(byt);



3. RMI上传大文件

把文件写一个modle ,把文件信息转化一下到mod里 ,并且序列化

public class FileInformation implements Serializable {

   String filename;
   String contentType;
   byte[] content;

   public String getFilename() {
return filename;
   }

public String getContentType() {
return contentType;
   }

public byte[] getContent() {
return content;
   }

public FileInformation(String filename,String contentType,byte[] content){
this.filename = filename;
       this.contentType = contentType;
       this.content = content;

   }

}



4. 完成代码的结构调整(出先很大错误)

把上传文件和短信,手机验证码的相关移动到WEB那里

暂时调整完成:


进度: 

         任务开始时间:11.09

         预计完成时间:11.12

          是否有延期风险:可能有,我想看看dubbo

禅道:http://task.ptteng.com/zentao/project-task-264.htm




返回列表 返回列表
评论

    分享到