|
@@ -14,6 +14,8 @@ import cn.reghao.jutil.jdk.security.DigestUtil;
|
|
|
import cn.reghao.jutil.web.ServletUtil;
|
|
import cn.reghao.jutil.web.ServletUtil;
|
|
|
import cn.reghao.oss.api.dto.OssPayload;
|
|
import cn.reghao.oss.api.dto.OssPayload;
|
|
|
import cn.reghao.oss.api.rest.UploadFileRet;
|
|
import cn.reghao.oss.api.rest.UploadFileRet;
|
|
|
|
|
+import cn.reghao.oss.store.util.StringUtil;
|
|
|
|
|
+import cn.reghao.oss.store.util.UserContext;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -51,8 +53,8 @@ public class ObjectUploadController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping(value = "/")
|
|
@PostMapping(value = "/")
|
|
|
- public ResponseEntity<String> postObject(MultipartFile file, Integer channelId, String client, String sha256sum)
|
|
|
|
|
- throws Exception {
|
|
|
|
|
|
|
+ public ResponseEntity<String> postObject(MultipartFile file, Integer channelId,
|
|
|
|
|
+ String client, String sha256sum, long userId) throws Exception {
|
|
|
/* permission check */
|
|
/* permission check */
|
|
|
if (client == null) {
|
|
if (client == null) {
|
|
|
String token = ServletUtil.getBearerToken();
|
|
String token = ServletUtil.getBearerToken();
|
|
@@ -73,8 +75,11 @@ public class ObjectUploadController {
|
|
|
return ResponseEntity.status(HttpStatus.FORBIDDEN)
|
|
return ResponseEntity.status(HttpStatus.FORBIDDEN)
|
|
|
.body(WebResult.failWithMsg("channel not match in token"));
|
|
.body(WebResult.failWithMsg("channel not match in token"));
|
|
|
}
|
|
}
|
|
|
- /*long userId1 = ossPayload.getUserId();
|
|
|
|
|
- UserContext context = new UserContext(userId1);*/
|
|
|
|
|
|
|
+
|
|
|
|
|
+ long userId1 = ossPayload.getUserId();
|
|
|
|
|
+ UserContext context = new UserContext(userId1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ UserContext context = new UserContext(userId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* channel validate */
|
|
/* channel validate */
|
|
@@ -88,7 +93,11 @@ public class ObjectUploadController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* store file */
|
|
/* store file */
|
|
|
- String sha256sum1 = DigestUtil.sha256sum(savedFile.getAbsolutePath());
|
|
|
|
|
|
|
+ String sha256sum1 = sha256sum;
|
|
|
|
|
+ if (sha256sum1 == null) {
|
|
|
|
|
+ sha256sum1 = DigestUtil.sha256sum(savedFile.getAbsolutePath());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String filename = file.getOriginalFilename();
|
|
String filename = file.getOriginalFilename();
|
|
|
if (filename == null) {
|
|
if (filename == null) {
|
|
|
filename = "";
|
|
filename = "";
|