I am doing a project on UDP client server file transfer in which a client successfully reads a file and transfers it to the server. But this works only as long as the file is a .txt
Any suggestions on how to make it work for .pdf files also. Thanks in advance :)
I already implemented tcp and it works fine. I figured out that what I was converting the byte array to string and then writing to file and thus some error was occuring
I fixed it by directly writing byte array to file rather than first converting it to string. Thanks for the help. :)
Related
Hi and thanks in advance,
So I have a program which already creates a socket and can send strings both ways between the server and client using UDP.
However, I need to ask something before I continue with trying to send a file (specifically a text file) over my connection.
Is there a way to physically send an actual file over the connection as apposed to simply sending the files contents, or does sending it contents count as sending the files itself?
I just want to make sure on this before I continue with my program.
Thank you.
A file is not a physical object. It is more an idea of interpreting your disks magnetical (or electrical) state.
A "file" is mainly its content. There is some additional information like permissions, owner, last edit date and so on. But I assume that you don't want to send these information.
I have no idea what the specific goal is you are trying to achieve but it is safe to say, that for most applications it is perfectly fine to think of the contents of a file when saying "file".
I am writing a basic client-server program where I send a file from the client to the server. I using a BufferedReader to upload the file from the client to the server, but I had a question about where it would exactly be stored on the server.
From my understanding, buffer memory is only temporary and doesn't necessarily save information. So how would I ensure that a file would be saved on the server? Thanks in advance.
BufferedReader doesn't store the whole stream in memory, just parts of the stream so you are aren't reading a byte at a time from I/O.
You'll need to read in the entire stream with BufferedReader, and store it in memory, assuming you have enough space, using something like StringBuilder, or store it on the server file system by using a FileWriter.
I have a Java client/server desktop application, where the communication between client and server is based on Sockets, and the messages exchanged between client and server are serialized objects (message objects, that incapsulate requests and responses).
Now I need to make the client able to upload a file from the local computer to the server, but I can't send the File through the buffer, since the Buffer is already used for exchanging the message objects.
Should i open another stream to send the file, or is there any better way to upload a file for my situation?
I need to make the client able to upload a file from the local computer to the server
- Open a Solely Dedicated Connection to the Server for File uploading.
- Use File Transfer Protocol to ease your work, and moreover its quite easy and reliable to use the Apache's common lib for File uploading and downloading....
See this link:
http://commons.apache.org/net/
You really only have two options:
Open another connection dedicated to the file upload and send it through that.
Make a message object representing bits of a file being uploaded, and send the file in chunks via these message objects.
The former seems simpler & cleaner to me, requiring less overhead and less complicated code.
You can keep your solution and pass the file content as an object, for example as a String - use Base64 encoding (or similar) of the content if it contains troublesome characters
i'm decoding and encoding a videofile via Xuggle to FLV-video format and send it via Sockets to my java server (not the entire file, only parts of it every X seconds). On the server-side I get the encoded file as ByteArrayInputStream. Is it possible to stream this ByteArrayInputStream via rtp or http-streaming? Or do i need a finished encoded file for that? I'm creating a video streaming server, where the client encodes the video file and sends it to the server in parts. This is already done. I'm now stuck on the server side, to stream the ByteArrayInputStream via RTP or HTTP, so I can watch it via VLC. Are there any good examples for it?
I've already tested to save the ByteArrayInputStream to file. This works but I don't wanna save the file on the server. I wanna stream it ;)
Thank you
1) See Server implementation
http://cs.anu.edu.au/student/comp3310/2004/Labs/lab6/lab5.html
2) http://code.google.com/p/vlcj/ and see http://code.google.com/p/vlcj/wiki/Streaming
This problem pertains to Java
By using RandomAccessFile I intend to be able to also modify the file without blanking it.
The FTP protocol only barely supports random access reads and writes.
That is to say, an FTP client can use the REST command to start reading or writing from a particular offset, but it will always truncate the file from that point.