tamar-file-hub-client 0.0.11__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- file_hub_client/rpc/gen/file_service_pb2.py +7 -5
- file_hub_client/rpc/gen/file_service_pb2_grpc.py +3 -3
- file_hub_client/rpc/protos/file_service.proto +6 -1
- file_hub_client/schemas/__init__.py +2 -0
- file_hub_client/schemas/file.py +6 -0
- file_hub_client/services/file/async_file_service.py +14 -3
- file_hub_client/services/file/sync_file_service.py +14 -3
- file_hub_client/services/taple/async_taple_service.py +14 -2
- file_hub_client/services/taple/base_taple_service.py +13 -1
- file_hub_client/services/taple/sync_taple_service.py +14 -2
- {tamar_file_hub_client-0.0.11.dist-info → tamar_file_hub_client-0.1.0.dist-info}/METADATA +21 -6
- {tamar_file_hub_client-0.0.11.dist-info → tamar_file_hub_client-0.1.0.dist-info}/RECORD +14 -14
- {tamar_file_hub_client-0.0.11.dist-info → tamar_file_hub_client-0.1.0.dist-info}/WHEEL +0 -0
- {tamar_file_hub_client-0.0.11.dist-info → tamar_file_hub_client-0.1.0.dist-info}/top_level.txt +0 -0
@@ -26,7 +26,7 @@ from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__
|
|
26
26
|
from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2
|
27
27
|
|
28
28
|
|
29
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12\x66ile_service.proto\x12\x04\x66ile\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xab\x01\n\x04\x46ile\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tfolder_id\x18\x02 \x01(\t\x12\x11\n\tfile_name\x18\x03 \x01(\t\x12\x11\n\tfile_type\x18\x04 \x01(\t\x12.\n\ncreated_at\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nupdated_at\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xb7\x02\n\nUploadFile\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tfolder_id\x18\x02 \x01(\t\x12\x0f\n\x07\x66ile_id\x18\x03 \x01(\t\x12\x14\n\x0cstorage_type\x18\x04 \x01(\t\x12\x13\n\x0bstored_name\x18\x05 \x01(\t\x12\x13\n\x0bstored_path\x18\x06 \x01(\t\x12\x11\n\tfile_name\x18\x07 \x01(\t\x12\x11\n\tfile_size\x18\x08 \x01(\x03\x12\x10\n\x08\x66ile_ext\x18\t \x01(\t\x12\x11\n\tmime_type\x18\n \x01(\t\x12\x0e\n\x06status\x18\x0b \x01(\t\x12.\n\ncreated_at\x18\x0c \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nupdated_at\x18\r \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xdf\x01\n\x11UploadFileRequest\x12\x16\n\tfolder_id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x0f\n\x07\x63ontent\x18\x03 \x01(\x0c\x12\x11\n\tfile_type\x18\x04 \x01(\t\x12\x11\n\tmime_type\x18\x05 \x01(\t\x12\x19\n\x0cis_temporary\x18\x06 \x01(\x08H\x01\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x07 \x01(\x05H\x02\x88\x01\x01\x42\x0c\n\n_folder_idB\x0f\n\r_is_temporaryB\x11\n\x0f_expire_seconds\"\xf3\x01\n\x10UploadUrlRequest\x12\x16\n\tfolder_id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x11\n\tfile_type\x18\x03 \x01(\t\x12\x11\n\tmime_type\x18\x04 \x01(\t\x12\x11\n\tfile_size\x18\x05 \x01(\x03\x12\x11\n\tfile_hash\x18\x06 \x01(\t\x12\x19\n\x0cis_temporary\x18\x07 \x01(\x08H\x01\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x08 \x01(\x05H\x02\x88\x01\x01\x42\x0c\n\n_folder_idB\x0f\n\r_is_temporaryB\x11\n\x0f_expire_seconds\")\n\x16UploadCompletedRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\"u\n\x12\x44ownloadUrlRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x13\n\x06is_cdn\x18\x03 \x01(\x08H\x00\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\t\n\x07_is_cdnB\x11\n\x0f_expire_seconds\"\xd4\x01\n\x10ShareLinkRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x11\n\tis_public\x18\x02 \x01(\x08\x12\x14\n\x0c\x61\x63\x63\x65ss_scope\x18\x03 \x01(\t\x12\x1b\n\x0e\x65xpire_seconds\x18\x04 \x01(\x05H\x00\x88\x01\x01\x12\x17\n\nmax_access\x18\x05 \x01(\x05H\x01\x88\x01\x01\x12\x1b\n\x0eshare_password\x18\x06 \x01(\tH\x02\x88\x01\x01\x42\x11\n\x0f_expire_secondsB\r\n\x0b_max_accessB\x11\n\x0f_share_password\"\x82\x01\n\x10\x46ileVisitRequest\x12\x15\n\rfile_share_id\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63\x63\x65ss_type\x18\x02 \x01(\t\x12\x17\n\x0f\x61\x63\x63\x65ss_duration\x18\x03 \x01(\x05\x12)\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\"!\n\x0eGetFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\"6\n\x11RenameFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x10\n\x08new_name\x18\x02 \x01(\t\"$\n\x11\x44\x65leteFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\"\x8d\x02\n\x10ListFilesRequest\x12\x16\n\tfolder_id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x16\n\tfile_name\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x11\n\tfile_type\x18\x03 \x03(\t\x12\x1c\n\x0f\x63reated_by_role\x18\x04 \x01(\tH\x02\x88\x01\x01\x12\x17\n\ncreated_by\x18\x05 \x01(\tH\x03\x88\x01\x01\x12\x16\n\tpage_size\x18\x06 \x01(\x05H\x04\x88\x01\x01\x12\x11\n\x04page\x18\x07 \x01(\x05H\x05\x88\x01\x01\x42\x0c\n\n_folder_idB\x0c\n\n_file_nameB\x12\n\x10_created_by_roleB\r\n\x0b_created_byB\x0c\n\n_page_sizeB\x07\n\x05_page\"U\n\x12UploadFileResponse\x12\x18\n\x04\x66ile\x18\x01 \x01(\x0b\x32\n.file.File\x12%\n\x0bupload_file\x18\x02 \x01(\x0b\x32\x10.file.UploadFile\"a\n\x11UploadUrlResponse\x12\x18\n\x04\x66ile\x18\x01 \x01(\x0b\x32\n.file.File\x12%\n\x0bupload_file\x18\x02 \x01(\x0b\x32\x10.file.UploadFile\x12\x0b\n\x03url\x18\x03 \x01(\t\"\"\n\x13\x44ownloadUrlResponse\x12\x0b\n\x03url\x18\x01 \x01(\t\"*\n\x11ShareLinkResponse\x12\x15\n\rfile_share_id\x18\x01 \x01(\t\"-\n\x10\x46ileListResponse\x12\x19\n\x05\x66iles\x18\x01 \x03(\x0b\x32\n.file.File\"\x07\n\x05\x45mpty2\
|
29
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12\x66ile_service.proto\x12\x04\x66ile\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xab\x01\n\x04\x46ile\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tfolder_id\x18\x02 \x01(\t\x12\x11\n\tfile_name\x18\x03 \x01(\t\x12\x11\n\tfile_type\x18\x04 \x01(\t\x12.\n\ncreated_at\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nupdated_at\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xb7\x02\n\nUploadFile\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\tfolder_id\x18\x02 \x01(\t\x12\x0f\n\x07\x66ile_id\x18\x03 \x01(\t\x12\x14\n\x0cstorage_type\x18\x04 \x01(\t\x12\x13\n\x0bstored_name\x18\x05 \x01(\t\x12\x13\n\x0bstored_path\x18\x06 \x01(\t\x12\x11\n\tfile_name\x18\x07 \x01(\t\x12\x11\n\tfile_size\x18\x08 \x01(\x03\x12\x10\n\x08\x66ile_ext\x18\t \x01(\t\x12\x11\n\tmime_type\x18\n \x01(\t\x12\x0e\n\x06status\x18\x0b \x01(\t\x12.\n\ncreated_at\x18\x0c \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nupdated_at\x18\r \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xdf\x01\n\x11UploadFileRequest\x12\x16\n\tfolder_id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x0f\n\x07\x63ontent\x18\x03 \x01(\x0c\x12\x11\n\tfile_type\x18\x04 \x01(\t\x12\x11\n\tmime_type\x18\x05 \x01(\t\x12\x19\n\x0cis_temporary\x18\x06 \x01(\x08H\x01\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x07 \x01(\x05H\x02\x88\x01\x01\x42\x0c\n\n_folder_idB\x0f\n\r_is_temporaryB\x11\n\x0f_expire_seconds\"\xf3\x01\n\x10UploadUrlRequest\x12\x16\n\tfolder_id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x11\n\tfile_type\x18\x03 \x01(\t\x12\x11\n\tmime_type\x18\x04 \x01(\t\x12\x11\n\tfile_size\x18\x05 \x01(\x03\x12\x11\n\tfile_hash\x18\x06 \x01(\t\x12\x19\n\x0cis_temporary\x18\x07 \x01(\x08H\x01\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x08 \x01(\x05H\x02\x88\x01\x01\x42\x0c\n\n_folder_idB\x0f\n\r_is_temporaryB\x11\n\x0f_expire_seconds\")\n\x16UploadCompletedRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\"u\n\x12\x44ownloadUrlRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x13\n\x06is_cdn\x18\x03 \x01(\x08H\x00\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\t\n\x07_is_cdnB\x11\n\x0f_expire_seconds\"\xd4\x01\n\x10ShareLinkRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x11\n\tis_public\x18\x02 \x01(\x08\x12\x14\n\x0c\x61\x63\x63\x65ss_scope\x18\x03 \x01(\t\x12\x1b\n\x0e\x65xpire_seconds\x18\x04 \x01(\x05H\x00\x88\x01\x01\x12\x17\n\nmax_access\x18\x05 \x01(\x05H\x01\x88\x01\x01\x12\x1b\n\x0eshare_password\x18\x06 \x01(\tH\x02\x88\x01\x01\x42\x11\n\x0f_expire_secondsB\r\n\x0b_max_accessB\x11\n\x0f_share_password\"\x82\x01\n\x10\x46ileVisitRequest\x12\x15\n\rfile_share_id\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63\x63\x65ss_type\x18\x02 \x01(\t\x12\x17\n\x0f\x61\x63\x63\x65ss_duration\x18\x03 \x01(\x05\x12)\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\"!\n\x0eGetFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\"6\n\x11RenameFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x10\n\x08new_name\x18\x02 \x01(\t\"$\n\x11\x44\x65leteFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\"\x8d\x02\n\x10ListFilesRequest\x12\x16\n\tfolder_id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x16\n\tfile_name\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x11\n\tfile_type\x18\x03 \x03(\t\x12\x1c\n\x0f\x63reated_by_role\x18\x04 \x01(\tH\x02\x88\x01\x01\x12\x17\n\ncreated_by\x18\x05 \x01(\tH\x03\x88\x01\x01\x12\x16\n\tpage_size\x18\x06 \x01(\x05H\x04\x88\x01\x01\x12\x11\n\x04page\x18\x07 \x01(\x05H\x05\x88\x01\x01\x42\x0c\n\n_folder_idB\x0c\n\n_file_nameB\x12\n\x10_created_by_roleB\r\n\x0b_created_byB\x0c\n\n_page_sizeB\x07\n\x05_page\"U\n\x12UploadFileResponse\x12\x18\n\x04\x66ile\x18\x01 \x01(\x0b\x32\n.file.File\x12%\n\x0bupload_file\x18\x02 \x01(\x0b\x32\x10.file.UploadFile\"a\n\x11UploadUrlResponse\x12\x18\n\x04\x66ile\x18\x01 \x01(\x0b\x32\n.file.File\x12%\n\x0bupload_file\x18\x02 \x01(\x0b\x32\x10.file.UploadFile\x12\x0b\n\x03url\x18\x03 \x01(\t\"\"\n\x13\x44ownloadUrlResponse\x12\x0b\n\x03url\x18\x01 \x01(\t\"*\n\x11ShareLinkResponse\x12\x15\n\rfile_share_id\x18\x01 \x01(\t\"-\n\x10\x46ileListResponse\x12\x19\n\x05\x66iles\x18\x01 \x03(\x0b\x32\n.file.File\"g\n\x0fGetFileResponse\x12\x18\n\x04\x66ile\x18\x01 \x01(\x0b\x32\n.file.File\x12*\n\x0bupload_file\x18\x02 \x01(\x0b\x32\x10.file.UploadFileH\x00\x88\x01\x01\x42\x0e\n\x0c_upload_file\"\x07\n\x05\x45mpty2\xc8\x05\n\x0b\x46ileService\x12?\n\nUploadFile\x12\x17.file.UploadFileRequest\x1a\x18.file.UploadFileResponse\x12\x44\n\x11GenerateUploadUrl\x12\x16.file.UploadUrlRequest\x1a\x17.file.UploadUrlResponse\x12M\n\x1aGenerateResumableUploadUrl\x12\x16.file.UploadUrlRequest\x1a\x17.file.UploadUrlResponse\x12\x43\n\x16\x43onfirmUploadCompleted\x12\x1c.file.UploadCompletedRequest\x1a\x0b.file.Empty\x12J\n\x13GenerateDownloadUrl\x12\x18.file.DownloadUrlRequest\x1a\x19.file.DownloadUrlResponse\x12\x44\n\x11GenerateShareLink\x12\x16.file.ShareLinkRequest\x1a\x17.file.ShareLinkResponse\x12\x30\n\tVisitFile\x12\x16.file.FileVisitRequest\x1a\x0b.file.Empty\x12\x36\n\x07GetFile\x12\x14.file.GetFileRequest\x1a\x15.file.GetFileResponse\x12\x31\n\nRenameFile\x12\x17.file.RenameFileRequest\x1a\n.file.File\x12\x32\n\nDeleteFile\x12\x17.file.DeleteFileRequest\x1a\x0b.file.Empty\x12;\n\tListFiles\x12\x16.file.ListFilesRequest\x1a\x16.file.FileListResponseb\x06proto3')
|
30
30
|
|
31
31
|
_globals = globals()
|
32
32
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
@@ -67,8 +67,10 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
67
67
|
_globals['_SHARELINKRESPONSE']._serialized_end=2226
|
68
68
|
_globals['_FILELISTRESPONSE']._serialized_start=2228
|
69
69
|
_globals['_FILELISTRESPONSE']._serialized_end=2273
|
70
|
-
_globals['
|
71
|
-
_globals['
|
72
|
-
_globals['
|
73
|
-
_globals['
|
70
|
+
_globals['_GETFILERESPONSE']._serialized_start=2275
|
71
|
+
_globals['_GETFILERESPONSE']._serialized_end=2378
|
72
|
+
_globals['_EMPTY']._serialized_start=2380
|
73
|
+
_globals['_EMPTY']._serialized_end=2387
|
74
|
+
_globals['_FILESERVICE']._serialized_start=2390
|
75
|
+
_globals['_FILESERVICE']._serialized_end=3102
|
74
76
|
# @@protoc_insertion_point(module_scope)
|
@@ -74,7 +74,7 @@ class FileServiceStub(object):
|
|
74
74
|
self.GetFile = channel.unary_unary(
|
75
75
|
'/file.FileService/GetFile',
|
76
76
|
request_serializer=file__service__pb2.GetFileRequest.SerializeToString,
|
77
|
-
response_deserializer=file__service__pb2.
|
77
|
+
response_deserializer=file__service__pb2.GetFileResponse.FromString,
|
78
78
|
_registered_method=True)
|
79
79
|
self.RenameFile = channel.unary_unary(
|
80
80
|
'/file.FileService/RenameFile',
|
@@ -205,7 +205,7 @@ def add_FileServiceServicer_to_server(servicer, server):
|
|
205
205
|
'GetFile': grpc.unary_unary_rpc_method_handler(
|
206
206
|
servicer.GetFile,
|
207
207
|
request_deserializer=file__service__pb2.GetFileRequest.FromString,
|
208
|
-
response_serializer=file__service__pb2.
|
208
|
+
response_serializer=file__service__pb2.GetFileResponse.SerializeToString,
|
209
209
|
),
|
210
210
|
'RenameFile': grpc.unary_unary_rpc_method_handler(
|
211
211
|
servicer.RenameFile,
|
@@ -440,7 +440,7 @@ class FileService(object):
|
|
440
440
|
target,
|
441
441
|
'/file.FileService/GetFile',
|
442
442
|
file__service__pb2.GetFileRequest.SerializeToString,
|
443
|
-
file__service__pb2.
|
443
|
+
file__service__pb2.GetFileResponse.FromString,
|
444
444
|
options,
|
445
445
|
channel_credentials,
|
446
446
|
insecure,
|
@@ -15,7 +15,7 @@ service FileService {
|
|
15
15
|
rpc GenerateDownloadUrl (DownloadUrlRequest) returns (DownloadUrlResponse);
|
16
16
|
rpc GenerateShareLink (ShareLinkRequest) returns (ShareLinkResponse);
|
17
17
|
rpc VisitFile (FileVisitRequest) returns (Empty);
|
18
|
-
rpc GetFile (GetFileRequest) returns (
|
18
|
+
rpc GetFile (GetFileRequest) returns (GetFileResponse);
|
19
19
|
rpc RenameFile (RenameFileRequest) returns (File);
|
20
20
|
rpc DeleteFile (DeleteFileRequest) returns (Empty);
|
21
21
|
rpc ListFiles (ListFilesRequest) returns (FileListResponse);
|
@@ -145,4 +145,9 @@ message FileListResponse {
|
|
145
145
|
repeated File files = 1;
|
146
146
|
}
|
147
147
|
|
148
|
+
message GetFileResponse {
|
149
|
+
File file = 1;
|
150
|
+
optional UploadFile upload_file = 2;
|
151
|
+
}
|
152
|
+
|
148
153
|
message Empty {}
|
@@ -10,6 +10,7 @@ from .file import (
|
|
10
10
|
FileVisitRequest,
|
11
11
|
FileListRequest,
|
12
12
|
FileListResponse,
|
13
|
+
GetFileResponse,
|
13
14
|
)
|
14
15
|
from .folder import (
|
15
16
|
FolderInfo,
|
@@ -61,6 +62,7 @@ __all__ = [
|
|
61
62
|
"FileVisitRequest",
|
62
63
|
"FileListRequest",
|
63
64
|
"FileListResponse",
|
65
|
+
"GetFileResponse",
|
64
66
|
|
65
67
|
# 文件夹相关
|
66
68
|
"FolderInfo",
|
file_hub_client/schemas/file.py
CHANGED
@@ -87,3 +87,9 @@ class FileListRequest(BaseModel):
|
|
87
87
|
class FileListResponse(BaseModel):
|
88
88
|
"""文件列表响应"""
|
89
89
|
files: List[File] = Field(default_factory=list, description="文件列表")
|
90
|
+
|
91
|
+
|
92
|
+
class GetFileResponse(BaseModel):
|
93
|
+
"""获取文件响应"""
|
94
|
+
file: File = Field(..., description="文件信息")
|
95
|
+
upload_file: Optional[UploadFile] = Field(None, description="上传文件信息")
|
@@ -11,6 +11,7 @@ from ...rpc.async_client import AsyncGrpcClient
|
|
11
11
|
from ...schemas import (
|
12
12
|
File,
|
13
13
|
FileListResponse,
|
14
|
+
GetFileResponse,
|
14
15
|
)
|
15
16
|
from ...errors import FileNotFoundError
|
16
17
|
|
@@ -120,7 +121,7 @@ class AsyncFileService(BaseFileService):
|
|
120
121
|
await stub.VisitFile(request, metadata=grpc_metadata)
|
121
122
|
|
122
123
|
async def get_file(self, file_id: str, request_id: Optional[str] = None,
|
123
|
-
**metadata) ->
|
124
|
+
**metadata) -> GetFileResponse:
|
124
125
|
"""
|
125
126
|
获取文件信息
|
126
127
|
|
@@ -129,9 +130,10 @@ class AsyncFileService(BaseFileService):
|
|
129
130
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
130
131
|
|
131
132
|
Returns:
|
132
|
-
|
133
|
+
文件信息响应,包含文件信息和上传文件信息
|
133
134
|
"""
|
134
135
|
from ...rpc.gen import file_service_pb2, file_service_pb2_grpc
|
136
|
+
from ...schemas.file import GetFileResponse
|
135
137
|
|
136
138
|
stub = await self.client.get_stub(file_service_pb2_grpc.FileServiceStub)
|
137
139
|
|
@@ -142,7 +144,16 @@ class AsyncFileService(BaseFileService):
|
|
142
144
|
|
143
145
|
try:
|
144
146
|
response = await stub.GetFile(request, metadata=grpc_metadata)
|
145
|
-
|
147
|
+
|
148
|
+
# 转换文件信息
|
149
|
+
file_info = self._convert_file_info(response.file)
|
150
|
+
|
151
|
+
# 转换上传文件信息(如果存在)
|
152
|
+
upload_file_info = None
|
153
|
+
if response.HasField('upload_file'):
|
154
|
+
upload_file_info = self._convert_upload_file_info(response.upload_file)
|
155
|
+
|
156
|
+
return GetFileResponse(file=file_info, upload_file=upload_file_info)
|
146
157
|
except grpc.RpcError as e:
|
147
158
|
if e.code() == grpc.StatusCode.NOT_FOUND:
|
148
159
|
raise FileNotFoundError(file_id)
|
@@ -9,6 +9,7 @@ from ...rpc.sync_client import SyncGrpcClient
|
|
9
9
|
from ...schemas import (
|
10
10
|
File,
|
11
11
|
FileListResponse,
|
12
|
+
GetFileResponse,
|
12
13
|
)
|
13
14
|
from ...errors import FileNotFoundError
|
14
15
|
|
@@ -118,7 +119,7 @@ class SyncFileService(BaseFileService):
|
|
118
119
|
stub.VisitFile(request, metadata=grpc_metadata)
|
119
120
|
|
120
121
|
def get_file(self, file_id: str, request_id: Optional[str] = None,
|
121
|
-
**metadata) ->
|
122
|
+
**metadata) -> GetFileResponse:
|
122
123
|
"""
|
123
124
|
获取文件信息
|
124
125
|
|
@@ -127,9 +128,10 @@ class SyncFileService(BaseFileService):
|
|
127
128
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
128
129
|
|
129
130
|
Returns:
|
130
|
-
|
131
|
+
文件信息响应,包含文件信息和上传文件信息
|
131
132
|
"""
|
132
133
|
from ...rpc.gen import file_service_pb2, file_service_pb2_grpc
|
134
|
+
from ...schemas.file import GetFileResponse
|
133
135
|
|
134
136
|
stub = self.client.get_stub(file_service_pb2_grpc.FileServiceStub)
|
135
137
|
|
@@ -140,7 +142,16 @@ class SyncFileService(BaseFileService):
|
|
140
142
|
|
141
143
|
try:
|
142
144
|
response = stub.GetFile(request, metadata=grpc_metadata)
|
143
|
-
|
145
|
+
|
146
|
+
# 转换文件信息
|
147
|
+
file_info = self._convert_file_info(response.file)
|
148
|
+
|
149
|
+
# 转换上传文件信息(如果存在)
|
150
|
+
upload_file_info = None
|
151
|
+
if response.HasField('upload_file'):
|
152
|
+
upload_file_info = self._convert_upload_file_info(response.upload_file)
|
153
|
+
|
154
|
+
return GetFileResponse(file=file_info, upload_file=upload_file_info)
|
144
155
|
except grpc.RpcError as e:
|
145
156
|
if e.code() == grpc.StatusCode.NOT_FOUND:
|
146
157
|
raise FileNotFoundError(file_id)
|
@@ -2058,7 +2058,7 @@ class AsyncTapleService(BaseTapleService):
|
|
2058
2058
|
"""
|
2059
2059
|
from ...rpc.gen import taple_service_pb2, taple_service_pb2_grpc
|
2060
2060
|
from ...schemas.taple import TableViewResponse
|
2061
|
-
|
2061
|
+
|
2062
2062
|
|
2063
2063
|
stub = await self.client.get_stub(taple_service_pb2_grpc.TapleServiceStub)
|
2064
2064
|
|
@@ -2166,7 +2166,19 @@ class AsyncTapleService(BaseTapleService):
|
|
2166
2166
|
from google.protobuf.json_format import MessageToDict
|
2167
2167
|
|
2168
2168
|
# 处理 visible_columns 的转换
|
2169
|
-
|
2169
|
+
if proto_view.HasField('visible_columns'):
|
2170
|
+
visible_columns_dict = MessageToDict(proto_view.visible_columns)
|
2171
|
+
# 如果服务器返回的是旧格式(包含 items 字段的结构),需要转换
|
2172
|
+
if isinstance(visible_columns_dict, dict) and 'items' in visible_columns_dict:
|
2173
|
+
# 旧格式:将列表转换为字典,默认所有列都显示
|
2174
|
+
if isinstance(visible_columns_dict['items'], list):
|
2175
|
+
visible_columns = {col: True for col in visible_columns_dict['items']}
|
2176
|
+
else:
|
2177
|
+
visible_columns = visible_columns_dict
|
2178
|
+
else:
|
2179
|
+
visible_columns = visible_columns_dict
|
2180
|
+
else:
|
2181
|
+
visible_columns = None
|
2170
2182
|
|
2171
2183
|
return TableView(
|
2172
2184
|
id=proto_view.id,
|
@@ -159,7 +159,19 @@ class BaseTapleService(IdempotentTapleMixin):
|
|
159
159
|
config = MessageToDict(proto_view.config) if proto_view.HasField('config') else {}
|
160
160
|
filter_criteria = MessageToDict(proto_view.filter_criteria) if proto_view.HasField('filter_criteria') else None
|
161
161
|
sort_criteria = MessageToDict(proto_view.sort_criteria) if proto_view.HasField('sort_criteria') else None
|
162
|
-
|
162
|
+
if proto_view.HasField('visible_columns'):
|
163
|
+
visible_columns_dict = MessageToDict(proto_view.visible_columns)
|
164
|
+
# 如果服务器返回的是旧格式(包含 items 字段的结构),需要转换
|
165
|
+
if isinstance(visible_columns_dict, dict) and 'items' in visible_columns_dict:
|
166
|
+
# 旧格式:将列表转换为字典,默认所有列都显示
|
167
|
+
if isinstance(visible_columns_dict['items'], list):
|
168
|
+
visible_columns = {col: True for col in visible_columns_dict['items']}
|
169
|
+
else:
|
170
|
+
visible_columns = visible_columns_dict
|
171
|
+
else:
|
172
|
+
visible_columns = visible_columns_dict
|
173
|
+
else:
|
174
|
+
visible_columns = None
|
163
175
|
group_criteria = MessageToDict(proto_view.group_criteria) if proto_view.HasField('group_criteria') else None
|
164
176
|
|
165
177
|
return TableView(
|
@@ -2033,7 +2033,7 @@ class SyncTapleService(BaseTapleService):
|
|
2033
2033
|
"""
|
2034
2034
|
from ...rpc.gen import taple_service_pb2, taple_service_pb2_grpc
|
2035
2035
|
from ...schemas.taple import TableViewResponse
|
2036
|
-
|
2036
|
+
|
2037
2037
|
|
2038
2038
|
stub = self.client.get_stub(taple_service_pb2_grpc.TapleServiceStub)
|
2039
2039
|
|
@@ -2141,7 +2141,19 @@ class SyncTapleService(BaseTapleService):
|
|
2141
2141
|
from google.protobuf.json_format import MessageToDict
|
2142
2142
|
|
2143
2143
|
# 处理 visible_columns 的转换
|
2144
|
-
|
2144
|
+
if proto_view.HasField('visible_columns'):
|
2145
|
+
visible_columns_dict = MessageToDict(proto_view.visible_columns)
|
2146
|
+
# 如果服务器返回的是旧格式(包含 items 字段的结构),需要转换
|
2147
|
+
if isinstance(visible_columns_dict, dict) and 'items' in visible_columns_dict:
|
2148
|
+
# 旧格式:将列表转换为字典,默认所有列都显示
|
2149
|
+
if isinstance(visible_columns_dict['items'], list):
|
2150
|
+
visible_columns = {col: True for col in visible_columns_dict['items']}
|
2151
|
+
else:
|
2152
|
+
visible_columns = visible_columns_dict
|
2153
|
+
else:
|
2154
|
+
visible_columns = visible_columns_dict
|
2155
|
+
else:
|
2156
|
+
visible_columns = None
|
2145
2157
|
|
2146
2158
|
return TableView(
|
2147
2159
|
id=proto_view.id,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: tamar-file-hub-client
|
3
|
-
Version: 0.0
|
3
|
+
Version: 0.1.0
|
4
4
|
Summary: A Python SDK for gRPC-based file management system
|
5
5
|
Home-page: https://github.com/Tamar-Edge-AI/file-hub-client
|
6
6
|
Author: Oscar Ou
|
@@ -695,11 +695,23 @@ async with AsyncTamarFileHubClient() as client:
|
|
695
695
|
# 设置用户上下文
|
696
696
|
client.set_user_context(org_id="123", user_id="456")
|
697
697
|
|
698
|
-
#
|
699
|
-
|
698
|
+
# 获取文件详细信息(返回 GetFileResponse 对象)
|
699
|
+
response = await client.files.get_file(file_id="file-001")
|
700
|
+
|
701
|
+
# 访问文件基本信息
|
702
|
+
file_info = response.file
|
703
|
+
print(f"文件ID: {file_info.id}")
|
700
704
|
print(f"文件名: {file_info.file_name}")
|
701
|
-
print(f"
|
705
|
+
print(f"文件类型: {file_info.file_type}")
|
702
706
|
print(f"创建时间: {file_info.created_at}")
|
707
|
+
|
708
|
+
# 访问上传文件详细信息(如果存在)
|
709
|
+
if response.upload_file:
|
710
|
+
upload_info = response.upload_file
|
711
|
+
print(f"文件大小: {upload_info.file_size} bytes")
|
712
|
+
print(f"MIME类型: {upload_info.mime_type}")
|
713
|
+
print(f"存储类型: {upload_info.storage_type}")
|
714
|
+
print(f"存储路径: {upload_info.stored_path}")
|
703
715
|
```
|
704
716
|
|
705
717
|
#### 重命名文件
|
@@ -1622,10 +1634,12 @@ folder = await client.folders.create_folder(
|
|
1622
1634
|
|
1623
1635
|
# 同步客户端同样支持
|
1624
1636
|
sync_client = TamarFileHubClient(user_context=user_context)
|
1625
|
-
|
1637
|
+
response = sync_client.files.get_file(
|
1626
1638
|
file_id="file-123",
|
1627
1639
|
request_id="debug-get-file-001"
|
1628
1640
|
)
|
1641
|
+
# response.file 包含文件基本信息
|
1642
|
+
# response.upload_file 包含上传文件详细信息(可能为None)
|
1629
1643
|
```
|
1630
1644
|
|
1631
1645
|
#### 请求ID优先级
|
@@ -1679,7 +1693,8 @@ await minimal_client.taples.create_table(name="auto_generated")
|
|
1679
1693
|
- 所有批量操作方法
|
1680
1694
|
|
1681
1695
|
**文件服务**:
|
1682
|
-
- `get_file()
|
1696
|
+
- `get_file()` - 返回 `GetFileResponse` 对象,包含 `file` 和 `upload_file` 信息
|
1697
|
+
- `rename_file()`, `delete_file()`, `list_files()`
|
1683
1698
|
- `generate_share_link()`, `visit_file()`
|
1684
1699
|
|
1685
1700
|
**文件夹服务**:
|
@@ -13,35 +13,35 @@ file_hub_client/rpc/generate_grpc.py,sha256=opzstxWdW7vqR9OxrgUCSUkZe8IqgcOdruqW
|
|
13
13
|
file_hub_client/rpc/interceptors.py,sha256=UeQ8u-olMiYwScXJrlzqPS-odGomH-h3xJqOwPznRUo,22071
|
14
14
|
file_hub_client/rpc/sync_client.py,sha256=ZWBmP-TU8eeAfl2lV8sLu9nsxo_aOPAVmt9ww_T8Hwg,14054
|
15
15
|
file_hub_client/rpc/gen/__init__.py,sha256=NJLqr9ezUXeOyy1J0sMPn3Kl_8IyGw7GAzzzewO3MIw,45
|
16
|
-
file_hub_client/rpc/gen/file_service_pb2.py,sha256=
|
17
|
-
file_hub_client/rpc/gen/file_service_pb2_grpc.py,sha256=
|
16
|
+
file_hub_client/rpc/gen/file_service_pb2.py,sha256=i8RsHLj8Vzoj0SXBNDtAVuUG6vwj96iTqOMoHE94-24,8733
|
17
|
+
file_hub_client/rpc/gen/file_service_pb2_grpc.py,sha256=KSf-kiA6M5YOmhySAMJIfLj3-cQamS59wEnULOP-DhI,20756
|
18
18
|
file_hub_client/rpc/gen/folder_service_pb2.py,sha256=OPNYHThmL1k2KH1ll2L_Gj76oWBWqcymXKHu8mk1Zvk,4126
|
19
19
|
file_hub_client/rpc/gen/folder_service_pb2_grpc.py,sha256=pOHFsVThdAu5DAKd8QK3_zQvUmFgGlh4KBqIYnYDZ_U,10411
|
20
20
|
file_hub_client/rpc/gen/taple_service_pb2.py,sha256=8BJCFRFJ_khl_Uaw-5jWCabljWJo6zaqOYWe1368xEw,48254
|
21
21
|
file_hub_client/rpc/gen/taple_service_pb2_grpc.py,sha256=DCL-45PlEZ0guLz1u2fFH_sDIT_awuSvp9Ak6fa2GO8,64773
|
22
|
-
file_hub_client/rpc/protos/file_service.proto,sha256=
|
22
|
+
file_hub_client/rpc/protos/file_service.proto,sha256=Rs57mVJ7Tl5NM2wXU8LcUBxvboHKcyzQiAhEt5_Ryq0,3799
|
23
23
|
file_hub_client/rpc/protos/folder_service.proto,sha256=cgIbJT2slXMMRGrtrzN3kjae9-4CB1zXCmceiUgE6fI,1542
|
24
24
|
file_hub_client/rpc/protos/taple_service.proto,sha256=0mwhyBwD3yvFhMiiSA6J3Ni6pyHc369iD4oDXXl7DIU,29765
|
25
|
-
file_hub_client/schemas/__init__.py,sha256=
|
25
|
+
file_hub_client/schemas/__init__.py,sha256=IpWfQe71MJLt9lK5Bh0PDIhmWGzLAQTa9qSUWbRz3xc,2146
|
26
26
|
file_hub_client/schemas/context.py,sha256=bs-KXGBBo_9i1KbvozY8KjYzV5ZtMbjqpPW_ssN7qMs,5516
|
27
|
-
file_hub_client/schemas/file.py,sha256=
|
27
|
+
file_hub_client/schemas/file.py,sha256=xn-5l8MqEhm78qbcddDvwAWITz9O4uuq-MJzBM_x2LQ,3829
|
28
28
|
file_hub_client/schemas/folder.py,sha256=D7UFsLCou-7CCXCQvuRObaBQEGmETsm1cgGOG1ceSrk,1026
|
29
29
|
file_hub_client/schemas/taple.py,sha256=LYsECsDbcioPXcvjRBcCEbh083iEB-eFCapJrGMJ8w0,17790
|
30
30
|
file_hub_client/services/__init__.py,sha256=yh5mir0dKB_LtJMk2hTpQI9WSlguaxtVD2KomMnzxdM,514
|
31
31
|
file_hub_client/services/file/__init__.py,sha256=aJygo_AzYk5NN-ezp-a9YlugJ82wVIP9e5e54fl0UsI,342
|
32
32
|
file_hub_client/services/file/async_blob_service.py,sha256=kIsz-tGDLgmk4J5I-h95Aummz1UPo55ffy5vIAFQxaU,20578
|
33
|
-
file_hub_client/services/file/async_file_service.py,sha256=
|
33
|
+
file_hub_client/services/file/async_file_service.py,sha256=wJuoy-3CiIow5Xef_4JNJRKEOoMTKfs9nxqbkaYI4Ig,9110
|
34
34
|
file_hub_client/services/file/base_file_service.py,sha256=wTxplrTk9klfwIHOPfTL0TQd6gX4nEmkYtIhpiZ3GVo,4791
|
35
35
|
file_hub_client/services/file/sync_blob_service.py,sha256=I2_fcdpE6jyZ4Bs7-zWzr5PhWWPMfKQLcYMuYV2cDiE,20359
|
36
|
-
file_hub_client/services/file/sync_file_service.py,sha256=
|
36
|
+
file_hub_client/services/file/sync_file_service.py,sha256=fMTq91dXwZzuMsPTZ1whaQBxzpyHfSP-A4W15pWSNfs,8964
|
37
37
|
file_hub_client/services/folder/__init__.py,sha256=vGbMOlNiEBdnWZB1xE74RJtoroI28hKHCWfQV1GqKQc,210
|
38
38
|
file_hub_client/services/folder/async_folder_service.py,sha256=uFEmtW8EXYvaKYT2JCitWbdTGR1EtHlx_eBN5P3JUZg,7293
|
39
39
|
file_hub_client/services/folder/sync_folder_service.py,sha256=T00k1nD0txjOFQXxeIbF_ZOkNUhsBF45sDxyaDk8rf8,7167
|
40
40
|
file_hub_client/services/taple/__init__.py,sha256=AQgYVRXgISye8cRd0J5QEK-5AoepeAw5726esFzs2Gg,199
|
41
|
-
file_hub_client/services/taple/async_taple_service.py,sha256=
|
42
|
-
file_hub_client/services/taple/base_taple_service.py,sha256=
|
41
|
+
file_hub_client/services/taple/async_taple_service.py,sha256=XZqMBN69FSJ8-n0nyIfqmjKG_ROpW57qPiB3RJ5FJK8,88859
|
42
|
+
file_hub_client/services/taple/base_taple_service.py,sha256=m_RZjvlXD8CzsB4gtZWDKiL7TNYYtRuSeY4yrFDnGIs,15842
|
43
43
|
file_hub_client/services/taple/idempotent_taple_mixin.py,sha256=lZeMF59dU-KVnc2p7epGrclidCv0nYg8TP_qVUezJ48,4295
|
44
|
-
file_hub_client/services/taple/sync_taple_service.py,sha256=
|
44
|
+
file_hub_client/services/taple/sync_taple_service.py,sha256=LIfpJjZjUPpee5zidrmiRD-tTXPouSlU4RpScy5kNZY,87392
|
45
45
|
file_hub_client/utils/__init__.py,sha256=0WS1R9VEPEqIN6_ksHEbO6Eu0G1Ps6oNTuOtoDMdDMM,1832
|
46
46
|
file_hub_client/utils/converter.py,sha256=TX69Bqk-PwNdv2hYQ07_tW6HQnQycHcJkGeRnskeF3A,3734
|
47
47
|
file_hub_client/utils/download_helper.py,sha256=Mc8TQSWjHxIglJMkKlGy9r3LZe8e_Mwe6D3sfn6IOnY,13338
|
@@ -51,7 +51,7 @@ file_hub_client/utils/logging.py,sha256=IxcvWkA0G9s9BMiXIeFAdJX5G-Lc5-JFlS2yxOX1
|
|
51
51
|
file_hub_client/utils/retry.py,sha256=A2MBdJCEY-Ks0guq8dd5wXX22sD27N30Qy3nQIW1B_s,18019
|
52
52
|
file_hub_client/utils/smart_retry.py,sha256=RjBhyG6SNDfMXxNxKU_qayWDD6Ihp7ow6_BPjhgflM0,16465
|
53
53
|
file_hub_client/utils/upload_helper.py,sha256=gEtn9OXVJiGUpVev_fqrDnRQ6AFiiP9goLzFrVpqXmU,22569
|
54
|
-
tamar_file_hub_client-0.0.
|
55
|
-
tamar_file_hub_client-0.0.
|
56
|
-
tamar_file_hub_client-0.0.
|
57
|
-
tamar_file_hub_client-0.0.
|
54
|
+
tamar_file_hub_client-0.1.0.dist-info/METADATA,sha256=nqxmyLYky2aZi1vvmHEDVE6lZDVRF0akTnreQ2_GocY,65575
|
55
|
+
tamar_file_hub_client-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
56
|
+
tamar_file_hub_client-0.1.0.dist-info/top_level.txt,sha256=9wcR7hyAJQdJg_kuH6WR3nmpJ8O-j8aJNK8f_kcFy6U,16
|
57
|
+
tamar_file_hub_client-0.1.0.dist-info/RECORD,,
|
File without changes
|
{tamar_file_hub_client-0.0.11.dist-info → tamar_file_hub_client-0.1.0.dist-info}/top_level.txt
RENAMED
File without changes
|