@@ -27,6 +27,55 @@ service FileService {
27
27
rpc GetFile (GetFileRequest ) returns (GetFileResponse ) {}
28
28
// Update a file from the Agent to the Server
29
29
rpc UpdateFile (UpdateFileRequest ) returns (UpdateFileResponse ) {}
30
+
31
+ // GetFileStream requests the file content in chunks. MP and agent should agree on size to use stream
32
+ // vs non-stream. For smaller files, it may be more efficient to not-stream.
33
+ rpc GetFileStream (GetFileRequest ) returns (stream FileDataChunk ) {}
34
+
35
+ // UpdateFileStream uploads the file content in streams. MP and agent should agree on size to use stream
36
+ // vs non-stream. For smaller files, it may be more efficient to not-stream.
37
+ rpc UpdateFileStream (stream FileDataChunk ) returns (UpdateFileResponse ) {}
38
+ }
39
+
40
+ // Represents a data chunk for streaming file transfer.
41
+ // For any Stream file transfer, following assumptions should be asserted (by implementation):
42
+ // - invalid to contain more or less than one FileDataChunkHeaders
43
+ // - invalid to have FileDataChunkContents before FileDataChunkHeaders
44
+ // - invalid to have more/fewer FileDataChunkContents than FileDataChunkHeader.chunks
45
+ // - invalid to have two FileDataChunkContents with same chunk_id
46
+ // - invalid to have FileDataChunkContent with zero-length data
47
+ // - invalid to have FileDataChunk message without either header or content
48
+ // - hash of the combined contents should match FileDataChunkHeader.file_meta.hash
49
+ // - total size of the combined contents should match FileDataChunkHeader.file_meta.size
50
+ // - chunk_size should be less than the gRPC max message size
51
+ message FileDataChunk {
52
+ // meta regarding the transfer request
53
+ mpi.v1.MessageMeta meta = 1 ;
54
+ oneof chunk {
55
+ // Chunk header
56
+ FileDataChunkHeader header = 2 ;
57
+ // Chunk data
58
+ FileDataChunkContent content = 3 ;
59
+ }
60
+ }
61
+
62
+ // Represents a chunked resource Header
63
+ message FileDataChunkHeader {
64
+ // meta regarding the file, help identity the file name, size, hash, perm
65
+ // receiver should validate the hash against the combined contents
66
+ FileMeta file_meta = 1 ;
67
+ // total number of chunks expected in the transfer
68
+ uint32 chunks = 2 [(buf.validate.field ).uint32 = { gt : 0 }];
69
+ // max size of individual chunks, can be undersized if EOF
70
+ uint32 chunk_size = 3 [(buf.validate.field ).uint32 = { gt : 0 }];
71
+ }
72
+
73
+ // Represents a chunked resource chunk
74
+ message FileDataChunkContent {
75
+ // chunk id, i.e. x of y, zero-indexed
76
+ uint32 chunk_id = 1 ;
77
+ // chunk data, should be at most chunk_size
78
+ bytes data = 2 ;
30
79
}
31
80
32
81
// Represents a request payload for a file overview
0 commit comments