简体   繁体   中英

audio streaming to the server

i'm trying to create an application in flash that will record the sound from the user and will save the data on the server. can I do this saving the recorded audio to the server by using java script or java servlets and not by php?

Question is too common, but definitely you can. As an concept you can try something like that. Override doPost method in your servlet:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InputStream in = (InputStream) request.getInputStream();

    int read = 0;
    byte[] bytes = new byte[1024];
    while ((read = in.read(bytes)) != -1) {
        // save your data
    }
    in.close();
}

On the client side just post portions of data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM