|
@@ -1,17 +1,14 @@
|
|
package cn.com.qmth.examcloud.exchange.inner.api.provider;
|
|
package cn.com.qmth.examcloud.exchange.inner.api.provider;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
|
-import javax.servlet.ServletInputStream;
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-
|
|
|
|
-import org.apache.poi.util.IOUtils;
|
|
|
|
|
|
+import org.apache.commons.fileupload.disk.DiskFileItem;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.base.exception.ExamCloudRuntimeException;
|
|
|
|
import cn.com.qmth.examcloud.commons.base.util.AES;
|
|
import cn.com.qmth.examcloud.commons.base.util.AES;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.exchange.inner.api.UpyunCloudService;
|
|
import cn.com.qmth.examcloud.exchange.inner.api.UpyunCloudService;
|
|
@@ -41,29 +38,21 @@ public class UpyunCloudServiceProvider extends ControllerSupport implements Upyu
|
|
@PostMapping("putFile")
|
|
@PostMapping("putFile")
|
|
@Override
|
|
@Override
|
|
public PutFileResp putFile(PutFileReq req) {
|
|
public PutFileResp putFile(PutFileReq req) {
|
|
- HttpServletRequest request = getRequest();
|
|
|
|
String fileSuffix = req.getFileSuffix();
|
|
String fileSuffix = req.getFileSuffix();
|
|
Long rootOrgId = req.getRootOrgId();
|
|
Long rootOrgId = req.getRootOrgId();
|
|
Long userId = req.getUserId();
|
|
Long userId = req.getUserId();
|
|
String siteId = req.getSiteId();
|
|
String siteId = req.getSiteId();
|
|
|
|
+ CommonsMultipartFile file = req.getFile();
|
|
|
|
+ DiskFileItem item = (DiskFileItem) file.getFileItem();
|
|
|
|
+ File storeLocation = item.getStoreLocation();
|
|
|
|
|
|
- ServletInputStream in = null;
|
|
|
|
- String url;
|
|
|
|
- try {
|
|
|
|
- in = request.getInputStream();
|
|
|
|
-
|
|
|
|
- UpyunPathEnvironmentInfo env = new UpyunPathEnvironmentInfo();
|
|
|
|
- env.setRootOrgId(String.valueOf(rootOrgId));
|
|
|
|
- env.setUserId(String.valueOf(userId));
|
|
|
|
- env.setFileSuffix(fileSuffix);
|
|
|
|
- url = upyunService.writeFile(siteId, env, in);
|
|
|
|
- url = aes.encrypt(url);
|
|
|
|
|
|
+ UpyunPathEnvironmentInfo env = new UpyunPathEnvironmentInfo();
|
|
|
|
+ env.setRootOrgId(String.valueOf(rootOrgId));
|
|
|
|
+ env.setUserId(String.valueOf(userId));
|
|
|
|
+ env.setFileSuffix(fileSuffix);
|
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- throw new ExamCloudRuntimeException(e);
|
|
|
|
- } finally {
|
|
|
|
- IOUtils.closeQuietly(in);
|
|
|
|
- }
|
|
|
|
|
|
+ String url = upyunService.writeFile(siteId, env, storeLocation);
|
|
|
|
+ url = aes.encrypt(url);
|
|
|
|
|
|
PutFileResp resp = new PutFileResp();
|
|
PutFileResp resp = new PutFileResp();
|
|
resp.setUrl(url);
|
|
resp.setUrl(url);
|