简体   繁体   English

音频流到服务器

[英]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. 我正在尝试创建一个Flash应用程序,该应用程序将记录用户的声音并将数据保存在服务器上。 can I do this saving the recorded audio to the server by using java script or java servlets and not by php? 如何使用Java脚本或Java Servlet而不是php将录制的音频保存到服务器?

Question is too common, but definitely you can. 问题太普遍了,但绝对可以。 As an concept you can try something like that. 作为一个概念,您可以尝试类似的方法。 Override doPost method in your servlet: 覆盖servlet中的doPost方法:

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. 在客户端,只需发布​​部分数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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