Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java后台如何获取image值啊? #39

Closed
zhangwei900808 opened this issue Nov 21, 2017 · 9 comments
Closed

java后台如何获取image值啊? #39

zhangwei900808 opened this issue Nov 21, 2017 · 9 comments

Comments

@zhangwei900808
Copy link

我现在不知道java后台如何获取这个data值

this.$refs.cropper.getCropData((data) => {
                this.$refs.avatarForm.reset();
                this.$post(`${this.$url}/teacher/uploadFileToQiniu`,{
                    imgStream : data
                })
                .then(res=>{

                })
                .catch(err=>{

                })
            })
@xyxiao001
Copy link
Owner

这样传过去就是base64的值

@zhangwei900808
Copy link
Author

大神可知道如何获取,java后台

@xyxiao001
Copy link
Owner

@zhangwei900808
Copy link
Author

有没有其它的方式获取这个图片啊

@xyxiao001
Copy link
Owner

blob 表单提交也可以

@zhangwei900808
Copy link
Author

获取截图的blob数据
this.$refs.cropper.getCropBlob((data) => {
// do something
console.log(data)
})

看到了:)

@zhangwei900808
Copy link
Author

现在不知道后台如何获取了

@xyxiao001
Copy link
Owner

可以塞到formdata 里面用表单提交过去

@zhangwei900808
Copy link
Author

对的,已经成功了,谢谢了:)

this.$refs.cropper.getCropBlob((data) => {
                this.$refs.avatarForm.reset();

                let formdata = new FormData();
  	            formdata.append('imgStream',data);
                
                let config = {
                        headers:{'Content-Type': 'multipart/form-data'  //之前说的以表单传数据的格式来传递fromdata
                    }
                };

                this.$post(`${this.$url}/teacher/uploadFileToQiniu`,formdata,config)
                .then(res=>{

                })
                .catch(err=>{

                })
            })
@PostMapping("/uploadFileToQiniu")
    public String uploadFileToQiniu(@RequestParam("imgStream") MultipartFile imgStream) throws IOException {
        AjaxResult result = new AjaxResult();

        InputStream content = imgStream.getInputStream();

        qiniuService.uploadFile(content);
        result.setMsg("上传成功");
        result.setSuccess(true);
        return JSON.toJSONString(result);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants