支持显示上传进度,优化部分代码
This commit is contained in:
parent
f19f5defcb
commit
aa5dfdbe5a
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue