Просмотр исходного кода

Merge branch 'release_real_202103' of https://git.malls.iformall.com/server/formallProject into release_real_202103

release_toaliyun_real
xhxu 5 лет назад
Родитель
Сommit
b1aac0b30c
4 измененных файлов: 32 добавлений и 8 удалений
  1. +25
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/video/VideoController.java
  2. +2
    -1
      mallinkVideo/src/main/java/com/iformall/video/VideoExcutor.java
  3. +4
    -5
      mallinkVideo/src/main/java/com/iformall/video/aliyun/AliyunVideoExcutor.java
  4. +1
    -1
      mallinkVideo/src/main/java/com/iformall/video/aliyun/sdk/upload/AliyunVedioUpload.java

+ 25
- 1
mallinkAdmin/src/main/java/com/iformall/controller/video/VideoController.java Просмотреть файл

@@ -17,6 +17,7 @@ import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxPropertyContract; import com.iformall.domain.po.WxPropertyContract;
import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxRentContract;
import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxShop;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.base.BaseEntity.SortField; import com.iformall.domain.po.base.BaseEntity.SortField;
import com.iformall.enums.EnumContractOperationType; import com.iformall.enums.EnumContractOperationType;
import com.iformall.enums.EnumContractType; import com.iformall.enums.EnumContractType;
@@ -40,12 +41,14 @@ import com.iformall.video.entity.VideUploadResult;


import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;


import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -70,12 +73,33 @@ public class VideoController extends BaseController {
@Autowired @Autowired
String videoType; String videoType;


@GetMapping("/upload")
@GetMapping("/test")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "title", value = "页数", dataType = "String", paramType = "query", required = true)}) @ApiImplicitParam(name = "title", value = "页数", dataType = "String", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxPropertyContract wxPropertyContract, String title) { public ResultData list(@ModelAttribute WxPropertyContract wxPropertyContract, String title) {
VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo("123123213", "/root/111.mp4"); VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo("123123213", "/root/111.mp4");
return new ResultData(result); return new ResultData(result);
} }
/**
* 上传视频
*
* @param multiReq
* @return
* @throws Exception
*/
@PostMapping(value = "/upload", consumes = "multipart/*", headers = "content-type=multipart/form-data")
@ApiOperation("上传视频")
@SystemControllerLog(description = "文件上传")
public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) {
try {
String title = param.get("title");
VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream());
return new ResultData(result);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR);
}
}


} }

+ 2
- 1
mallinkVideo/src/main/java/com/iformall/video/VideoExcutor.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.video; package com.iformall.video;


import java.io.File; import java.io.File;
import java.io.InputStream;


import com.iformall.video.entity.VideUploadResult; import com.iformall.video.entity.VideUploadResult;


@@ -12,7 +13,7 @@ public interface VideoExcutor {
*/ */
public VideUploadResult uploadLocalVideo(String title,String localFile); public VideUploadResult uploadLocalVideo(String title,String localFile);
public VideUploadResult uploadLocalVideo(String title,File localFile);
public VideUploadResult uploadLocalVideo(String title,InputStream inputStream);
//ext,后缀名 //ext,后缀名
public VideUploadResult uploadNetVideo(String title,String url,String ext); public VideUploadResult uploadNetVideo(String title,String url,String ext);


+ 4
- 5
mallinkVideo/src/main/java/com/iformall/video/aliyun/AliyunVideoExcutor.java Просмотреть файл

@@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;


import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -59,13 +60,11 @@ public class AliyunVideoExcutor implements VideoExcutor {
} }


@Override @Override
public VideUploadResult uploadLocalVideo(String title,File localFile) {
public VideUploadResult uploadLocalVideo(String title,InputStream inputStream) {
VideUploadResult result = new VideUploadResult(); VideUploadResult result = new VideUploadResult();
UploadStreamResponse response; UploadStreamResponse response;
FileInputStream inputStream = null;
try { try {
inputStream = new FileInputStream(localFile);
response = AliyunVedioUpload.uploadStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, localFile.getName(), inputStream);
response = AliyunVedioUpload.uploadStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, "", inputStream);
if (response.isSuccess()) { if (response.isSuccess()) {
result.setVideoId(response.getVideoId()); result.setVideoId(response.getVideoId());
result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); result.setVideoUrl(getUrlByVeidoId(response.getVideoId()));
@@ -74,7 +73,7 @@ public class AliyunVideoExcutor implements VideoExcutor {
result.setSuccess(false); result.setSuccess(false);
result.setMsg("ErrorCode["+response.getCode()+"]"+response.getMessage()); result.setMsg("ErrorCode["+response.getCode()+"]"+response.getMessage());
} }
} catch (FileNotFoundException e) {
} catch (Exception e) {
log.error("aliyun uploadLocalVideo error",e); log.error("aliyun uploadLocalVideo error",e);
result.setSuccess(false); result.setSuccess(false);
result.setMsg(e.getLocalizedMessage()); result.setMsg(e.getLocalizedMessage());


+ 1
- 1
mallinkVideo/src/main/java/com/iformall/video/aliyun/sdk/upload/AliyunVedioUpload.java Просмотреть файл

@@ -229,7 +229,7 @@ public class AliyunVedioUpload {
/* 网络文件下载读取超时,单位毫秒,0-表示不限制*/ /* 网络文件下载读取超时,单位毫秒,0-表示不限制*/
request.setDownloadReadTimeout(0); request.setDownloadReadTimeout(0);
/* 网络文件下载后保存的本地目录*/ /* 网络文件下载后保存的本地目录*/
request.setLocalDownloadFilePath("/Users/download");
request.setLocalDownloadFilePath("/aliyunvideo/download");
/* 是否显示水印(可选),指定模板组ID时,根据模板组配置确定是否显示水印*/ /* 是否显示水印(可选),指定模板组ID时,根据模板组配置确定是否显示水印*/
//request.setShowWaterMark(true); //request.setShowWaterMark(true);
/* 自定义消息回调设置(可选),参数说明参考文档 https://help.aliyun.com/document_detail/86952.html#UserData */ /* 自定义消息回调设置(可选),参数说明参考文档 https://help.aliyun.com/document_detail/86952.html#UserData */


Загрузка…
Отмена
Сохранить