Browse Source

支持显示上传进度,优化部分代码

main
zhouxin5253@163.com 4 years ago
parent
commit
fd12ea1e47
  1. 2
      src/main/java/com/github/zxbu/webdavteambition/store/TeambitionClientService.java
  2. 14
      src/main/java/com/github/zxbu/webdavteambition/store/TeambitionFileSystemStore.java

2
src/main/java/com/github/zxbu/webdavteambition/store/TeambitionClientService.java

@ -119,7 +119,7 @@ public class TeambitionClientService { @@ -119,7 +119,7 @@ public class TeambitionClientService {
return;
}
client.upload(oneUploadUrl, buffer, 0, read);
LOGGER.info("文件正在上传上传。文件名:{},当前进度:{}/{}", path, (i+1), uploadUrl.size());
LOGGER.info("文件正在上传。文件名:{},当前进度:{}/{}", path, (i+1), uploadUrl.size());
} catch (IOException e) {
throw new RuntimeException(e);

14
src/main/java/com/github/zxbu/webdavteambition/store/TeambitionFileSystemStore.java

@ -84,16 +84,18 @@ public class TeambitionFileSystemStore implements IWebdavStore { @@ -84,16 +84,18 @@ public class TeambitionFileSystemStore implements IWebdavStore {
LOGGER.info("setResourceContent {}", resourceUri);
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();
String expect = request.getHeader("Expect");
// 支持大文件上传
if ("100-continue".equalsIgnoreCase(expect)) {
return 0;
}
int contentLength = request.getContentLength();
if (contentLength < 0) {
contentLength = 0;
}
if (contentLength == 0) {
String expect = request.getHeader("Expect");
// 支持大文件上传
if ("100-continue".equalsIgnoreCase(expect)) {
return 0;
}
}
teambitionClientService.uploadPre(resourceUri, contentLength, content);
return contentLength;
}

Loading…
Cancel
Save