0

Cannot fire an event with large event data in Client side

asked 2019-12-12 17:00:03 +0800

DennyDeng1 gravatar image DennyDeng1
5 2

Hello, I am using ZK in my project, and I have a requirement that allow user to upload the screenshot from clipboard when he clicks "ctrl V", so I tried to implement that by event, my client code as follow:

_doPaste: function(evt) {
    if (evt && evt.domEvent && evt.domEvent.originalEvent && evt.domEvent.originalEvent.clipboardData) {
        var items = evt.domEvent.originalEvent.clipboardData.items;
        for (var i = 0; i < items.length; i++) {
            // Skip content if not image
            if (items[i].type.indexOf("image") == -1)
                continue;
            // Retrieve image on clipboard as blob
            var imageBlob = items[i].getAsFile();
            if (imageBlob) {
                var reader = new FileReader();
                var grid = this;
                reader.onload = function(e) {
                    var rawData = reader.result;
                    var base64Data = btoa(rawData);
                    grid.fire("onPasteImage", {imageData:base64Data});
                }
                reader.readAsBinaryString(imageBlob);
            }
        }
    }
}

It works when my screenshot is small size, e.g. the image is less than 1 MB. But if the screenshot size is 2 MB or larger, the action is down:

localhost:8080 says
The server is temporarily out of service
Would you like to try again?
(467)

The image will be converted to binary string and sent within the event to Server side, does the event data have the size limit? Do you have any better idea to send the image to server side rather than event?


Any idea is welcome, Thanks in advanced.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2019-12-16 12:29:32 +0800

cor3000 gravatar image cor3000
5920 2 7
ZK Team

first guess, you might just have run into your container's post size limit which is 2MB on tomcat by default http://tomcat.apache.org/tomcat-8.5-doc/config/http.html

https://stackoverflow.com/questions/2943477/is-there-a-max-size-for-post-parameter-content

maybe it's just this simple server configuration

link publish delete flag offensive edit

answered 2019-12-17 00:25:35 +0800

DennyDeng1 gravatar image DennyDeng1
5 2

first guess, you might just have run into your container's post size limit which is 2MB on tomcat by default

Thank you, it works.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2019-12-12 17:00:03 +0800

Seen: 18 times

Last updated: Dec 17 '19

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More