mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-17 21:59:52 +08:00
图片上传
This commit is contained in:
@@ -163,10 +163,16 @@ public class CommonController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传到阿里云oss
|
||||||
|
* http://localhost:8080/common/uploadOSS
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@PostMapping("/uploadOSS")
|
@PostMapping("/uploadOSS")
|
||||||
public AjaxResult uploadFileOSS(MultipartFile file) throws Exception {
|
public AjaxResult uploadFileOSS(MultipartFile file) throws Exception {
|
||||||
System.out.println(file);
|
|
||||||
try {
|
try {
|
||||||
String url = AliyunOssUploadUtils.uploadFile(file);
|
String url = AliyunOssUploadUtils.uploadFile(file);
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
|||||||
@@ -19,12 +19,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>上传图片</div>
|
<div>上传图片</div>
|
||||||
<el-upload
|
<el-upload
|
||||||
action="https://jsonplaceholder.typicode.com/posts/"
|
action="http://localhost:8080/common/uploadOSS"
|
||||||
|
:headers="headers"
|
||||||
list-type="picture-card"
|
list-type="picture-card"
|
||||||
:on-preview="handlePictureCardPreview"
|
:on-preview="handlePictureCardPreview"
|
||||||
:on-remove="handleRemove"
|
:on-remove="handleRemove"
|
||||||
|
:on-success="handleSuccess"
|
||||||
>
|
>
|
||||||
<!-- :headers="headers"-->
|
|
||||||
<i class="el-icon-plus"></i>
|
<i class="el-icon-plus"></i>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<el-dialog :visible.sync="dialogVisible">
|
<el-dialog :visible.sync="dialogVisible">
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
import AMapLoader from "@amap/amap-jsapi-loader";
|
import AMapLoader from "@amap/amap-jsapi-loader";
|
||||||
import {getStation} from "@/api/pile/station.js";
|
import {getStation} from "@/api/pile/station.js";
|
||||||
import bus from "@/bus/bus";
|
import bus from "@/bus/bus";
|
||||||
|
import {getToken} from "@/utils/auth";
|
||||||
|
|
||||||
window._AMapSecurityConfig = {
|
window._AMapSecurityConfig = {
|
||||||
securityJsCode: "829b6b73f84682c2eb982eaa47a745b8",
|
securityJsCode: "829b6b73f84682c2eb982eaa47a745b8",
|
||||||
@@ -75,9 +77,17 @@ export default {
|
|||||||
placeSearch: "",
|
placeSearch: "",
|
||||||
stationId: this.$route.params.id,
|
stationId: this.$route.params.id,
|
||||||
avatar: "",
|
avatar: "",
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer " + getToken()
|
||||||
|
},
|
||||||
|
imageUrl: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleSuccess(res, file) {
|
||||||
|
this.imageUrl = URL.createObjectURL(file.raw);
|
||||||
|
console.log("图片上传成功 url:", this.imageUrl);
|
||||||
|
},
|
||||||
handleRemove(file, fileList) {
|
handleRemove(file, fileList) {
|
||||||
console.log(file, fileList);
|
console.log(file, fileList);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user