parent
c293d155f6
commit
c7901bc7d8
@ -1,75 +1,75 @@
|
||||
package com.luoo.music.controller;
|
||||
|
||||
|
||||
import api.Result;
|
||||
import com.luoo.music.service.S3Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class S3Controller {
|
||||
|
||||
@Autowired
|
||||
private S3Service s3Service;
|
||||
|
||||
|
||||
@GetMapping("/awstest")
|
||||
public Result test() throws UnsupportedEncodingException {
|
||||
|
||||
// s3Service.listObjects()
|
||||
List list = s3Service.list();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件存储目录规划
|
||||
*
|
||||
* music 存放期刊和期刊歌曲 二级目录为期刊期刊号 三级目录存放期刊歌曲和封面图片和歌曲图片
|
||||
*
|
||||
* song 存放通用歌曲
|
||||
*
|
||||
* image存放图片
|
||||
*
|
||||
* img
|
||||
*
|
||||
* user/avatar/111.jpg
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@PostMapping("/awsUpload")
|
||||
public Result upload(MultipartFile file) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
// String fileName = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
||||
|
||||
|
||||
String filePath = sdf.format(new Date()) + "/" + file.getOriginalFilename();
|
||||
try{
|
||||
int code = s3Service.singleUpload("indie", filePath, file);
|
||||
|
||||
} catch (Exception ex){
|
||||
}
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/awsCopy")
|
||||
public Result copy() {
|
||||
s3Service.copy();
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
//package com.luoo.music.controller;
|
||||
//
|
||||
//
|
||||
//import api.Result;
|
||||
//import com.luoo.music.service.S3Service;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//
|
||||
//import java.io.UnsupportedEncodingException;
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RestController
|
||||
//@CrossOrigin
|
||||
//public class S3Controller {
|
||||
//
|
||||
// @Autowired
|
||||
// private S3Service s3Service;
|
||||
//
|
||||
//
|
||||
// @GetMapping("/awstest")
|
||||
// public Result test() throws UnsupportedEncodingException {
|
||||
//
|
||||
//// s3Service.listObjects()
|
||||
// List list = s3Service.list();
|
||||
// return Result.success();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 文件存储目录规划
|
||||
// *
|
||||
// * music 存放期刊和期刊歌曲 二级目录为期刊期刊号 三级目录存放期刊歌曲和封面图片和歌曲图片
|
||||
// *
|
||||
// * song 存放通用歌曲
|
||||
// *
|
||||
// * image存放图片
|
||||
// *
|
||||
// * img
|
||||
// *
|
||||
// * user/avatar/111.jpg
|
||||
// *
|
||||
// *
|
||||
// *
|
||||
// *
|
||||
// */
|
||||
// @PostMapping("/awsUpload")
|
||||
// public Result upload(MultipartFile file) {
|
||||
//
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
//// String fileName = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
||||
//
|
||||
//
|
||||
// String filePath = sdf.format(new Date()) + "/" + file.getOriginalFilename();
|
||||
// try{
|
||||
// int code = s3Service.singleUpload("indie", filePath, file);
|
||||
//
|
||||
// } catch (Exception ex){
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return Result.success();
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/awsCopy")
|
||||
// public Result copy() {
|
||||
// s3Service.copy();
|
||||
// return Result.success();
|
||||
// }
|
||||
//}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.luoo.music.response.cms;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author locust
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "文件上传后的路径")
|
||||
public class UploadRespDto {
|
||||
|
||||
@ApiModelProperty(value = "部分路径")
|
||||
private String partUrl;
|
||||
|
||||
@ApiModelProperty(value = "全路径")
|
||||
private String fullUrl;
|
||||
|
||||
@ApiModelProperty(value = "文件大小")
|
||||
private Long size;
|
||||
|
||||
@ApiModelProperty(value = "歌曲时长")
|
||||
private Long duration;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.luoo.music.util;
|
||||
|
||||
/**
|
||||
* @author locust
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public static String JOURNAL_NO_PREF = "VOL•";
|
||||
|
||||
private String SONG_PREF = "song";
|
||||
|
||||
|
||||
public static final String MUSIC_RESOURCE_PREFIX="http://cdn.indie.cn/music/";
|
||||
public static final String IMAGE_RESOURCE_PREFIX="http://cdn.indie.cn/image/";
|
||||
public static final String SONG_RESOURCE_PREFIX="http://cdn.indie.cn/song/";
|
||||
|
||||
|
||||
public static final String BUCKET = "indie";
|
||||
public static final String RESOURCE_PREFIX="http://cdn.indie.cn/";
|
||||
public static final String MUSIC_KEY_PREFIX = "music/";
|
||||
public static final String IMAGE_KEY_PREFIX = "image/";
|
||||
public static final String SONG_KEY_PREFIX = "song/";
|
||||
public static final String TEMP_KEY_PREFIX = "temp/";
|
||||
|
||||
public static final String DOT = ".";
|
||||
public static final String SLASH = "/";
|
||||
}
|
Loading…
Reference in new issue