Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

name of file

 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I transfer a file from a client to a server. It works fine. But the client transfer only data. How can I solve transfer with name of file?(I use ServerSocket, Socket, OutputStream, InputStream)

Thanks for your help
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "transfer with name of file" mean?. What else is there to transfer except for the data of the file (which you said works fine)?
 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
What does "transfer with name of file" mean?. What else is there to transfer except for the data of the file (which you said works fine)?



I transfer only data of file without filename. File > FileInputStream > BufferedInputStream > .... via OutputStream to net(tcp)

For example:
client binary.bin ... transfer file from parameter

but on server side I create my own name of file. I don't know how get filename of file which is send by client.
 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by manu chao:



I transfer only data of file without filename.

Client : File > FileInputStream > BufferedInputStream > .... via OutputStream to net(tcp)

For example:
client binary.bin ... transfer file from parameter

but on server side I create my own name of file. I don't know how get filename of file which is send by client.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before sending the data, can you send the file name over the same stream, with some pre-determined marker to separate the file name from the file data?
 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Before sending the data, can you send the file name over the same stream, with some pre-determined marker to separate the file name from the file data?


Yes, I can. And is it the best way?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's hard to say without knowing the circumstances. So far we only know that you have a single stream to work with.
 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
That's hard to say without knowing the circumstances. So far we only know that you have a single stream to work with.


I tried solution sending filename in first block.

But is it possibility to use ObjectInputStream, ObjectOutputStream for sending filename by any way?

Client:
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to use object streams?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic