Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8184083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:22:44+00:00 2026-06-07T01:22:44+00:00

I want to send a video file from a server written in java to

  • 0

I want to send a video file from a server written in java to a web browser client.
The socket connection works fine and I have no trouble sending text.
The library I’m using to make a socket server is this https://github.com/TooTallNate/Java-WebSocket

This is the code for sending the file

public void sendFile(WebSocket conn,String path)
{
 try
   {    
     File file = new File(path);
     byte[] data = new byte[(int)file.length()];
     DataInputStream stream = new DataInputStream(new FileInputStream(file));
     stream.readFully(data);
     stream.close();
     conn.send(data);
     ..snip catch statements..

Here is my javascript code for catching the file

function connect()
{
 conn = new WebSocket('ws://localhost:8887');
 conn.onopen = function(){alert("Connection Open");};
 conn.onmessage = function(evt){if(evt.data instanceof Blob){readFile(evt);}else{alert(evt.data);}};
 conn.onclose = function(){alert('connection closed');};
}
function readFile(file_data)
{
 var video = document.getElementById('area');
 video.src = window.URL.createObjectURL(file_data.data);
}

..skip to html element for playing the file..

<video id='area' controls="controls"></video>

I want to be able to receive the file in the browser and play it.

The error I get while trying to send a webm video file to fireox is:
HTTP “Content-Type” of “application/octet-stream” is not supported. Load of media resource blob:794345a5-4b6d-4585-b92b-3acb51612a6c failed.

Is it possible to receive a video file from a websocket and play it?
Am I implementing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:22:47+00:00Added an answer on June 7, 2026 at 1:22 am

    Video element requires right content-type, ws Blob comes with generic one, and it seems (to me) there is no way to set it serverside or clientside.
    Fortunately, Blob has slice(start, end, contentType) method:

    var rightBlob = originalBlob.slice(0, originalBlob.size, 'video/webm')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send video/images from the android mobile to a server and recieve
I want to attach a video and send email from my application. I downloaded
I want to send a live video stream to a server and I want
What I want I want to send a video from my SDcard to a
Hello Sir i want send list of data to php server i use following
Want to send the text from my current vb application to the Active Window
I want to send a opened file descriptor between two different programs. So I
I have a RTP video stream that I want to send to a set-top
I want to be able to send files from an iPhone app to a
I am recording a video from iPhone and I want to show the video

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.