|
@@ -10,6 +10,7 @@ import com.fdkankan.common.constant.UploadFilePath;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
import com.fdkankan.common.util.CreateObjUtil;
|
|
|
+import com.fdkankan.fyun.constant.StorageType;
|
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
import com.fdkankan.scene.entity.DownloadTourVideo;
|
|
@@ -19,7 +20,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.scene.vo.DownloadTourVideoVO;
|
|
|
import java.io.File;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import org.apache.http.HttpHeaders;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -42,6 +46,8 @@ public class DownloadTourVideoServiceImpl extends ServiceImpl<IDownloadTourVideo
|
|
|
private RabbitMqProducer rabbitMqProducer;
|
|
|
@Autowired
|
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
+ @Value("${upload.type}")
|
|
|
+ private String type;
|
|
|
|
|
|
@Override
|
|
|
public DownloadTourVideo getWaitingByNum(String num) {
|
|
@@ -106,7 +112,13 @@ public class DownloadTourVideoServiceImpl extends ServiceImpl<IDownloadTourVideo
|
|
|
CreateObjUtil.formatMp4(srcPath, destPath);
|
|
|
//上传到oss
|
|
|
String ossPath = String.format(UploadFilePath.DOWNLOADS_TOUR_VIDEO, downloadTourVideo.getNum()) + downloadTourVideo.getFileName();
|
|
|
- uploadToOssUtil.upload(destPath, ossPath);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put(HttpHeaders.CONTENT_TYPE, "application/octet-stream");
|
|
|
+ if(StorageType.OSS.code().equals(type)){
|
|
|
+ uploadToOssUtil.uploadOssWithHeaders(destPath, ossPath, headers);
|
|
|
+ }else{
|
|
|
+ uploadToOssUtil.uploadAwsWithHeaders(destPath, ossPath, headers);
|
|
|
+ }
|
|
|
downloadTourVideo.setDownloadPath(ossPath);
|
|
|
downloadTourVideo.setState(1);
|
|
|
this.updateById(downloadTourVideo);
|