2

I have files with data (payload) in different formats (plain text, json, xlm, binary (can be decoded by protobuf)). To know how to process particular file I need to know what is the format of data in the file.

The question is whether it is possible to recognize without having .proto (message) file that the payload in a file can be decoded by protobuf. So, if I know that it is protobuf encoded data, I will apply one logic where .proto file is required, otherwise, another logic without .proto file.

All what I've found requires to have protobuf message to validate/decode.

vich
  • 262
  • 2
  • 15
  • Don't quite follow - can't you just check the file extension? – lkallas May 15 '20 at 14:31
  • I corrected title and question. Obviously I was not fully correct and mixed "protobuf format" with "binary" which can be decoded using protobuf – vich May 15 '20 at 14:47

1 Answers1

0

Usually .proto files have something like syntax = "proto3"; as one of the first lines of the file. This does not apply to proto2 syntax though.

Maybe you can make use of that?

lkallas
  • 1,310
  • 5
  • 22
  • 36
  • no, I don't want to use .proto before I'm sure that file data (payload) is of protobuf format – vich May 15 '20 at 14:25