|
|
@@ -1,6 +1,7 @@
|
|
|
package cn.reghao.oss.sdk;
|
|
|
|
|
|
import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
+import cn.reghao.jutil.jdk.security.DigestUtil;
|
|
|
import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
|
import cn.reghao.oss.common.UploadFileRet;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
@@ -73,15 +74,18 @@ public class ObjectUploadService {
|
|
|
}
|
|
|
|
|
|
public UploadFileRet postObject(File file, int channelId) {
|
|
|
+ String authToken = "5c34161755e3d8b44e5f165ce1b91ef9";
|
|
|
try {
|
|
|
+ String sha256sum = DigestUtil.sha256sum(file.getAbsolutePath());
|
|
|
MultiPartBodyPublisher publisher = new MultiPartBodyPublisher()
|
|
|
.addPart("file", Paths.get(file.getAbsolutePath()))
|
|
|
+ .addPart("sha256sum", sha256sum)
|
|
|
.addPart("channelId", channelId+"");
|
|
|
|
|
|
String api = String.format("%s/", endpoint);
|
|
|
HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
|
|
|
.version(HttpClient.Version.HTTP_1_1)
|
|
|
- .header("Authorization", "5c34161755e3d8b44e5f165ce1b91ef9")
|
|
|
+ .header("Authorization", authToken)
|
|
|
.header("Content-Type", "multipart/form-data; boundary=" + publisher.getBoundary())
|
|
|
.POST(publisher.build())
|
|
|
.build();
|