使用Apache HttpClient 4.x实现可恢复文件上传是否有标准方法? 我试图覆盖 FileBody
中的 writeTo 方法@Override
public void writeTo(final OutputStream out) throws IOException {
if (out == null) {
throw new IllegalArgumentException("Output stream may not be null");
}
BufferedInputStream stream = new BufferedInputStream(new FileInputStream(this.file));
if(pos > 0){
stream.skip(pos);
}
刚才发现我可能需要覆盖 getContentLength 方法
public long getContentLength() {
return this.file.length() - pos;
}
或者,也许我可以这样做:
BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
if(pos > 0){
stream.skip(pos);
}
new InputStreamEntity(stream , file.getSize()-pos);
有人有建议吗?