Эх сурвалжийг харах

[task-6942] 下载文件流

xiexh 2 сар өмнө
parent
commit
fea99341ef

+ 1 - 0
ibps-basic-root/modules/basic-response/src/main/java/com/lc/ibps/cloud/config/AuthorizationConfig.java

@@ -192,6 +192,7 @@ public class AuthorizationConfig {
 		ignoreUrls.add("/ibps/platform/v3//file/download");//1
 		ignoreUrls.add("/ibps/platform/v3/file/download");//1
 		ignoreUrls.add("/file/download");//2
+		ignoreUrls.add("/file/downloadFileStream");
 
 		ignoreUrls.add("/employee/signInformation/query");
 		ignoreUrls.add("/employee/signInformation/save");

+ 11 - 0
ibps-comp-base-root/modules/comp-file-server-api/src/main/java/com/lc/ibps/file/server/api/IDownloadService.java

@@ -190,5 +190,16 @@ public interface IDownloadService {
 	 */
 	@RequestMapping(value = "/ueditor/action", method = {RequestMethod.GET})
 	public String ueditorAction(HttpServletRequest request);
+
+
+	/**
+	 * 下载文件流
+	 * @param attachmentId
+	 */
+	@RequestMapping(value = "/downloadFileStream", method = {RequestMethod.GET})
+	public void downloadFileStream(
+			@NotBlank(message = "{com.lc.ibps.cloud.file.attachmentId}")
+			@RequestParam(name = "attachmentId", required = true) String attachmentId);
+			//HttpServletResponse response);
 	
 }

+ 16 - 1
ibps-comp-root/modules/comp-file-server/src/main/java/com/lc/ibps/cloud/file/provider/DownloadProvider.java

@@ -684,5 +684,20 @@ public class DownloadProvider extends GenericUploadProvider implements IDownload
 		return "";
 	}
 
-	
+	@Override
+	public void downloadFileStream(String attachmentId) {
+		try {
+			this.getUploadService();
+			FileInfo fileInfo = uploadService.downloadFile(attachmentId);
+			if (BeanUtils.isNotEmpty(fileInfo)) {
+				byte[] fileBlob = fileInfo.getFileBytes();
+				String fileName = UploadUtil.getFileName(fileInfo.getFileName(), fileInfo.getExt());
+				RequestUtil.downLoadFileByByte(this.getRequest(), this.getResponse(), fileBlob, fileName);
+			}
+		} catch (Exception e) {
+			logger.error("/upload/download", e);
+		}
+	}
+
+
 }

+ 10 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/employee/provider/RegistrationOutsidersProvider.java

@@ -6,8 +6,11 @@ import java.util.Map;
 
 import javax.annotation.Resource;
 
+import com.lc.ibps.base.core.util.AppUtil;
 import com.lc.ibps.base.framework.id.UniqueIdUtil;
 import com.lc.ibps.components.employee.persistence.dao.RegistrationOutsidersDao;
+import com.lc.ibps.components.upload.UploadStrategySelector;
+import com.lc.ibps.components.upload.service.IUploadService;
 import com.lc.ibps.entrust.dao.RegistrationOutsidersMapperDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -148,10 +151,17 @@ public class RegistrationOutsidersProvider extends GenericProvider implements IR
 		APIResult<List<Map<String, Object>>> result = new APIResult();
 		try {
 			List<Map<String, Object>> dataList = registrationOutsidersMapperDao.getRegistrationOutsidersFileConfig();
+			IUploadService<?> uploadService = getUploadService();
+			byte[] file = uploadService.getFile("1465719865787547648");
 			result.setData(dataList);
 		} catch (Exception e) {
 			setExceptionResult(result, StateEnum.ERROR.getCode(), StateEnum.ERROR.getText(), e);
 		}
 		return result;
 	}
+
+	private IUploadService<?> getUploadService() {
+		UploadStrategySelector<?> uploadStrategySelector = AppUtil.getBean(UploadStrategySelector.class);
+		return uploadStrategySelector.getIUploadService(true);
+	}
 }