1. Front-end vue+webpackage+axios, back-end springboot
2. Zuul is used as the gateway and routing is configured. Authentication is carried out at the gateway entrance by writing token, in header
2. Use fastDFS as a file server and configure nginx for online preview
the online preview address of 3.fastDFS is not open to the public and is routed through zuul. This requires a token, so writing the image address directly to the src attribute of img is not feasible.
related codes
getimg(){
axios.get(process.env.BASE_API+"preview/group0/M00/00/00/rBQAHVtkLACAR2y9AAgEf2GW0sY139.png", {
responseType: "arraybuffer",
headers:{"validtoken":this.$store.getters.token}
}).then(response => {
return "data:image/png;base64," +btoa(new Uint8Array(response.data).reduce((data, byte) => data + String.fromCharCode(byte), ""));
}).then(data=>{
that.$refs.img.src=data;
});
you can see that the picture is requested, but how to display it on img? The above code is written with reference to the answer above https://codeshelper.com/q/10., but it is not shown. The last data of the console.log output is only the previous short paragraph" data:image/png;base64, "
.