如何创建 proto 文件以获取字节数组?

问题描述

我使用 GRPCMicroservices 之间发送数据。

我创建了一个 proto 文件,如下所示:

service Selfie {
    rpc AddSelfie(SelfieRequest) returns (SelfieResponse);
}

message SelfieRequest{
    string OwnerId = 1;
    byte[] File = 2;
}

message SelfieResponse {
    bool Status=1;
    float distance=2;
    string FileId=3;
}

当我构建我的项目时,它在 Byte[] 上出现错误

Selfie.proto(13,9):预期的字段名称

我该如何解决?谢谢

解决方法

Google Protobuf 不支持 byte[],我们可以用 bytes 代替 byte[]