对接接口方法:1.获取token2.更新案件状态3.上传文件4.推送案件附件信息
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.wisdomarbitrate.utils;
|
||||
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import java.io.InputStream;
|
||||
public class CommonInputStreamResource extends InputStreamResource {
|
||||
private long length;
|
||||
private String fileName;
|
||||
public CommonInputStreamResource(InputStream inputStream, long length, String fileName) {
|
||||
super(inputStream);
|
||||
this.length = length;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆写父类方法
|
||||
* 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常
|
||||
* {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded}
|
||||
*/
|
||||
@Override
|
||||
public String getFilename() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆写父类 contentLength 方法
|
||||
* 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件,
|
||||
* 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。
|
||||
*/
|
||||
@Override
|
||||
public long contentLength() {
|
||||
long estimate = length;
|
||||
return estimate == 0 ? 1 : estimate;
|
||||
}
|
||||
|
||||
public void setLength(long length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user