How to Post imageData(video) from Jsp to Spring MVC? -
the code use image data , post this, , imagedata uint8clampedarray , video stream. got error msg every time when try submit it. msg "uncaught typeerror: illegal invocation"
var imagedata = ctx.getimagedata(0, 0, width, height); $.ajax({ url: '/blog/saveblog', type: 'post', data:{videodata: videodata}, success: function (result) { loadmine(); } }); the server built in spring mvc, wrote controller handle post request, never in.
can me on problem? thanks.!
late answer, if can someone...
here 1 way post canvas data server
function(canvas) { $.post('/blog/saveblog', { image: canvas.todataurl() }, function(data) {...}); } and way manage on server side using spring mvc
@requestmapping(value = "/saveblog") @responsebody public void saveblog(@requestparam(value="image", required=false) string imagebase64) throws ioexception long = calendar.getinstance().gettimeinmillis(); byte[] bytes = imagebase64.replaceall("data:image/.+;base64,", "").getbytes(); file image= new file("./folder", "image.jpeg"); if(!image.exists()){ files.createparentdirs(image); } files.write(decoder.decode(bytes), image); } this works fine images, think should work video (need change line imagebase64.replaceall("data:image/.+;base64,", ""))
Comments
Post a Comment