@Override
public String startUploadFile(String localFilePath, int localFileLength, String remoteFilePath) throws RemoteException {
RFileUploadTransfer fileTransfer = new RFileUploadTransfer(localFilePath,localFileLength,remoteFilePath);
if(this.uploadFileStatusMonitor.containsKey(fileTransfer.getFileKey())) {
this.uploadFileStatusMonitor.remove(fileTransfer.getFileKey());
}
this.uploadFileStatusMonitor.put(fileTransfer.getFileKey(), fileTransfer);
return fileTransfer.getFileKey();
}
1.2.3 文件内容上传更新接口设计
文件内容上传更新接口名称为updateUploadProgress,主要功能是接收客户端传输过来的文件内容byte[]信息。其在接口实现类中的代码如下所示:
@Override
public boolean updateUploadProgress(String fileKey, byte[] contents) throws RemoteException {
if(this.uploadFileStatusMonitor.containsKey(fileKey)) {
RFileUploadTransfer fileTransfer = this.uploadFileStatusMonitor.get(fileKey);
fileTransfer.addContentBytes(contents);
if(fileTransfer.isSaveFile()) {
this.uploadFileStatusMonitor.remove(fileKey);
}
}
return true;
}
1.2.4 客户端设计