且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

服务器套接字文件传输

更新时间:2022-11-07 08:20:46

是,只需在实际文件内容之前传输元数据(在您的情况下为 myFile.getName()),并使客户端和服务器读取并发出该元数据。使用已建立的协议是个好主意,例如 HTTP 及其 Content-Disposition 标题。

Yes, simply transfer the metadata (in your case myFile.getName()) before the actual file contents, and make client and server read and emit that metadata. It's a good idea to use established protocols, for example HTTP and its Content-Disposition header.