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

This commit is contained in:
zhouxin5253@163.com 2021-01-18 21:12:06 +08:00
parent f19f5defcb
commit aa5dfdbe5a
2 changed files with 11 additions and 1 deletions

View File

@ -111,18 +111,22 @@ public class TeambitionClientService {
LOGGER.info("文件预处理成功,开始上传。文件名:{}上传URL数量{}", path, uploadUrl.size());
byte[] buffer = new byte[chunkSize];
for (String oneUploadUrl : uploadUrl) {
for (int i = 0; i < uploadUrl.size(); i++) {
String oneUploadUrl = uploadUrl.get(i);
try {
int read = IOUtils.read(inputStream, buffer, 0, buffer.length);
if (read == -1) {
return;
}
client.upload(oneUploadUrl, buffer, 0, read);
LOGGER.info("文件正在上传上传。文件名:{},当前进度:{}/{}", path, (i+1), uploadUrl.size());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
UploadFinalRequest uploadFinalRequest = new UploadFinalRequest();
uploadFinalRequest.setCcpFileId(uploadPreResult.getCcpFileId());
uploadFinalRequest.setDriveId(client.getDriveId());

View File

@ -84,6 +84,12 @@ 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;