You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
960 B
40 lines
960 B
syntax = "proto3";
|
|
|
|
package fileupload;
|
|
|
|
option go_package = "./fileupload";
|
|
|
|
// 文件上传服务定义
|
|
service FileUploadService {
|
|
// 上传文件的 RPC 方法,使用流式传输
|
|
rpc UploadFile (stream FileChunk) returns (UploadResponse);
|
|
}
|
|
|
|
// 文件数据块
|
|
message FileChunk {
|
|
// 文件元信息,只在第一个数据块中包含
|
|
FileInfo info = 1;
|
|
// 文件数据
|
|
bytes content = 2;
|
|
// 当前块的序号
|
|
int32 chunk_index = 3;
|
|
// 总块数
|
|
int32 total_chunks = 4;
|
|
}
|
|
|
|
// 文件元信息
|
|
message FileInfo {
|
|
string file_name = 1; // 文件名
|
|
int64 file_size = 2; // 文件大小(字节)
|
|
string content_type = 3; // 文件类型
|
|
string upload_path = 4; // 上传路径
|
|
}
|
|
|
|
// 上传响应
|
|
message UploadResponse {
|
|
bool success = 1; // 是否成功
|
|
string message = 2; // 响应消息
|
|
string file_path = 3; // 服务器保存路径
|
|
int64 received_size = 4; // 接收的文件大小
|
|
}
|
|
|