tamar-file-hub-client 0.1.1__py3-none-any.whl → 0.1.3__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 +52 -52
- file_hub_client/rpc/protos/file_service.proto +5 -1
- file_hub_client/schemas/__init__.py +2 -0
- file_hub_client/schemas/file.py +7 -0
- file_hub_client/services/file/async_blob_service.py +27 -4
- file_hub_client/services/file/sync_blob_service.py +27 -4
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.3.dist-info}/METADATA +163 -1
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.3.dist-info}/RECORD +10 -10
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.3.dist-info}/WHEEL +0 -0
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.3.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\"\
|
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\"\x9f\x02\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\x12#\n\x16keep_original_filename\x18\x08 \x01(\x08H\x03\x88\x01\x01\x42\x0c\n\n_folder_idB\x0f\n\r_is_temporaryB\x11\n\x0f_expire_secondsB\x19\n\x17_keep_original_filename\"\xb3\x02\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\x12#\n\x16keep_original_filename\x18\t \x01(\x08H\x03\x88\x01\x01\x42\x0c\n\n_folder_idB\x0f\n\r_is_temporaryB\x11\n\x0f_expire_secondsB\x19\n\x17_keep_original_filename\")\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\"{\n\x17\x42\x61tchDownloadUrlRequest\x12\x10\n\x08\x66ile_ids\x18\x01 \x03(\t\x12\x13\n\x06is_cdn\x18\x02 \x01(\x08H\x00\x88\x01\x01\x12\x1b\n\x0e\x65xpire_seconds\x18\x03 \x01(\x05H\x01\x88\x01\x01\x42\t\n\x07_is_cdnB\x11\n\x0f_expire_seconds\"#\n\x10GetGcsUrlRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\")\n\x15\x42\x61tchGetGcsUrlRequest\x12\x10\n\x08\x66ile_ids\x18\x01 \x03(\t\"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\"H\n\x18\x42\x61tchDownloadUrlResponse\x12,\n\rdownload_urls\x18\x01 \x03(\x0b\x32\x15.file.DownloadUrlInfo\"M\n\x0f\x44ownloadUrlInfo\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12\x12\n\x05\x65rror\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"7\n\x11GetGcsUrlResponse\x12\x0f\n\x07gcs_url\x18\x01 \x01(\t\x12\x11\n\tmime_type\x18\x02 \x01(\t\"<\n\x16\x42\x61tchGetGcsUrlResponse\x12\"\n\x08gcs_urls\x18\x01 \x03(\x0b\x32\x10.file.GcsUrlInfo\"_\n\nGcsUrlInfo\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x0f\n\x07gcs_url\x18\x02 \x01(\t\x12\x11\n\tmime_type\x18\x03 \x01(\t\x12\x12\n\x05\x65rror\x18\x04 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_error\"\x07\n\x05\x45mpty2\xae\x07\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\x12Y\n\x18\x42\x61tchGenerateDownloadUrl\x12\x1d.file.BatchDownloadUrlRequest\x1a\x1e.file.BatchDownloadUrlResponse\x12<\n\tGetGcsUrl\x12\x16.file.GetGcsUrlRequest\x1a\x17.file.GetGcsUrlResponse\x12K\n\x0e\x42\x61tchGetGcsUrl\x12\x1b.file.BatchGetGcsUrlRequest\x1a\x1c.file.BatchGetGcsUrlResponse\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)
|
@@ -38,55 +38,55 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
38
38
|
_globals['_UPLOADFILE']._serialized_start=266
|
39
39
|
_globals['_UPLOADFILE']._serialized_end=577
|
40
40
|
_globals['_UPLOADFILEREQUEST']._serialized_start=580
|
41
|
-
_globals['_UPLOADFILEREQUEST']._serialized_end=
|
42
|
-
_globals['_UPLOADURLREQUEST']._serialized_start=
|
43
|
-
_globals['_UPLOADURLREQUEST']._serialized_end=
|
44
|
-
_globals['_UPLOADCOMPLETEDREQUEST']._serialized_start=
|
45
|
-
_globals['_UPLOADCOMPLETEDREQUEST']._serialized_end=
|
46
|
-
_globals['_DOWNLOADURLREQUEST']._serialized_start=
|
47
|
-
_globals['_DOWNLOADURLREQUEST']._serialized_end=
|
48
|
-
_globals['_SHARELINKREQUEST']._serialized_start=
|
49
|
-
_globals['_SHARELINKREQUEST']._serialized_end=
|
50
|
-
_globals['_FILEVISITREQUEST']._serialized_start=
|
51
|
-
_globals['_FILEVISITREQUEST']._serialized_end=
|
52
|
-
_globals['_GETFILEREQUEST']._serialized_start=
|
53
|
-
_globals['_GETFILEREQUEST']._serialized_end=
|
54
|
-
_globals['_RENAMEFILEREQUEST']._serialized_start=
|
55
|
-
_globals['_RENAMEFILEREQUEST']._serialized_end=
|
56
|
-
_globals['_DELETEFILEREQUEST']._serialized_start=
|
57
|
-
_globals['_DELETEFILEREQUEST']._serialized_end=
|
58
|
-
_globals['_LISTFILESREQUEST']._serialized_start=
|
59
|
-
_globals['_LISTFILESREQUEST']._serialized_end=
|
60
|
-
_globals['_BATCHDOWNLOADURLREQUEST']._serialized_start=
|
61
|
-
_globals['_BATCHDOWNLOADURLREQUEST']._serialized_end=
|
62
|
-
_globals['_GETGCSURLREQUEST']._serialized_start=
|
63
|
-
_globals['_GETGCSURLREQUEST']._serialized_end=
|
64
|
-
_globals['_BATCHGETGCSURLREQUEST']._serialized_start=
|
65
|
-
_globals['_BATCHGETGCSURLREQUEST']._serialized_end=
|
66
|
-
_globals['_UPLOADFILERESPONSE']._serialized_start=
|
67
|
-
_globals['_UPLOADFILERESPONSE']._serialized_end=
|
68
|
-
_globals['_UPLOADURLRESPONSE']._serialized_start=
|
69
|
-
_globals['_UPLOADURLRESPONSE']._serialized_end=
|
70
|
-
_globals['_DOWNLOADURLRESPONSE']._serialized_start=
|
71
|
-
_globals['_DOWNLOADURLRESPONSE']._serialized_end=
|
72
|
-
_globals['_SHARELINKRESPONSE']._serialized_start=
|
73
|
-
_globals['_SHARELINKRESPONSE']._serialized_end=
|
74
|
-
_globals['_FILELISTRESPONSE']._serialized_start=
|
75
|
-
_globals['_FILELISTRESPONSE']._serialized_end=
|
76
|
-
_globals['_GETFILERESPONSE']._serialized_start=
|
77
|
-
_globals['_GETFILERESPONSE']._serialized_end=
|
78
|
-
_globals['_BATCHDOWNLOADURLRESPONSE']._serialized_start=
|
79
|
-
_globals['_BATCHDOWNLOADURLRESPONSE']._serialized_end=
|
80
|
-
_globals['_DOWNLOADURLINFO']._serialized_start=
|
81
|
-
_globals['_DOWNLOADURLINFO']._serialized_end=
|
82
|
-
_globals['_GETGCSURLRESPONSE']._serialized_start=
|
83
|
-
_globals['_GETGCSURLRESPONSE']._serialized_end=
|
84
|
-
_globals['_BATCHGETGCSURLRESPONSE']._serialized_start=
|
85
|
-
_globals['_BATCHGETGCSURLRESPONSE']._serialized_end=
|
86
|
-
_globals['_GCSURLINFO']._serialized_start=
|
87
|
-
_globals['_GCSURLINFO']._serialized_end=
|
88
|
-
_globals['_EMPTY']._serialized_start=
|
89
|
-
_globals['_EMPTY']._serialized_end=
|
90
|
-
_globals['_FILESERVICE']._serialized_start=
|
91
|
-
_globals['_FILESERVICE']._serialized_end=
|
41
|
+
_globals['_UPLOADFILEREQUEST']._serialized_end=867
|
42
|
+
_globals['_UPLOADURLREQUEST']._serialized_start=870
|
43
|
+
_globals['_UPLOADURLREQUEST']._serialized_end=1177
|
44
|
+
_globals['_UPLOADCOMPLETEDREQUEST']._serialized_start=1179
|
45
|
+
_globals['_UPLOADCOMPLETEDREQUEST']._serialized_end=1220
|
46
|
+
_globals['_DOWNLOADURLREQUEST']._serialized_start=1222
|
47
|
+
_globals['_DOWNLOADURLREQUEST']._serialized_end=1339
|
48
|
+
_globals['_SHARELINKREQUEST']._serialized_start=1342
|
49
|
+
_globals['_SHARELINKREQUEST']._serialized_end=1554
|
50
|
+
_globals['_FILEVISITREQUEST']._serialized_start=1557
|
51
|
+
_globals['_FILEVISITREQUEST']._serialized_end=1687
|
52
|
+
_globals['_GETFILEREQUEST']._serialized_start=1689
|
53
|
+
_globals['_GETFILEREQUEST']._serialized_end=1722
|
54
|
+
_globals['_RENAMEFILEREQUEST']._serialized_start=1724
|
55
|
+
_globals['_RENAMEFILEREQUEST']._serialized_end=1778
|
56
|
+
_globals['_DELETEFILEREQUEST']._serialized_start=1780
|
57
|
+
_globals['_DELETEFILEREQUEST']._serialized_end=1816
|
58
|
+
_globals['_LISTFILESREQUEST']._serialized_start=1819
|
59
|
+
_globals['_LISTFILESREQUEST']._serialized_end=2088
|
60
|
+
_globals['_BATCHDOWNLOADURLREQUEST']._serialized_start=2090
|
61
|
+
_globals['_BATCHDOWNLOADURLREQUEST']._serialized_end=2213
|
62
|
+
_globals['_GETGCSURLREQUEST']._serialized_start=2215
|
63
|
+
_globals['_GETGCSURLREQUEST']._serialized_end=2250
|
64
|
+
_globals['_BATCHGETGCSURLREQUEST']._serialized_start=2252
|
65
|
+
_globals['_BATCHGETGCSURLREQUEST']._serialized_end=2293
|
66
|
+
_globals['_UPLOADFILERESPONSE']._serialized_start=2295
|
67
|
+
_globals['_UPLOADFILERESPONSE']._serialized_end=2380
|
68
|
+
_globals['_UPLOADURLRESPONSE']._serialized_start=2382
|
69
|
+
_globals['_UPLOADURLRESPONSE']._serialized_end=2479
|
70
|
+
_globals['_DOWNLOADURLRESPONSE']._serialized_start=2481
|
71
|
+
_globals['_DOWNLOADURLRESPONSE']._serialized_end=2515
|
72
|
+
_globals['_SHARELINKRESPONSE']._serialized_start=2517
|
73
|
+
_globals['_SHARELINKRESPONSE']._serialized_end=2559
|
74
|
+
_globals['_FILELISTRESPONSE']._serialized_start=2561
|
75
|
+
_globals['_FILELISTRESPONSE']._serialized_end=2606
|
76
|
+
_globals['_GETFILERESPONSE']._serialized_start=2608
|
77
|
+
_globals['_GETFILERESPONSE']._serialized_end=2711
|
78
|
+
_globals['_BATCHDOWNLOADURLRESPONSE']._serialized_start=2713
|
79
|
+
_globals['_BATCHDOWNLOADURLRESPONSE']._serialized_end=2785
|
80
|
+
_globals['_DOWNLOADURLINFO']._serialized_start=2787
|
81
|
+
_globals['_DOWNLOADURLINFO']._serialized_end=2864
|
82
|
+
_globals['_GETGCSURLRESPONSE']._serialized_start=2866
|
83
|
+
_globals['_GETGCSURLRESPONSE']._serialized_end=2921
|
84
|
+
_globals['_BATCHGETGCSURLRESPONSE']._serialized_start=2923
|
85
|
+
_globals['_BATCHGETGCSURLRESPONSE']._serialized_end=2983
|
86
|
+
_globals['_GCSURLINFO']._serialized_start=2985
|
87
|
+
_globals['_GCSURLINFO']._serialized_end=3080
|
88
|
+
_globals['_EMPTY']._serialized_start=3082
|
89
|
+
_globals['_EMPTY']._serialized_end=3089
|
90
|
+
_globals['_FILESERVICE']._serialized_start=3092
|
91
|
+
_globals['_FILESERVICE']._serialized_end=4034
|
92
92
|
# @@protoc_insertion_point(module_scope)
|
@@ -61,6 +61,7 @@ message UploadFileRequest {
|
|
61
61
|
string mime_type = 5;
|
62
62
|
optional bool is_temporary = 6;
|
63
63
|
optional int32 expire_seconds = 7;
|
64
|
+
optional bool keep_original_filename = 8; // 保留原始文件名,默认false
|
64
65
|
}
|
65
66
|
|
66
67
|
message UploadUrlRequest {
|
@@ -72,6 +73,7 @@ message UploadUrlRequest {
|
|
72
73
|
string file_hash = 6;
|
73
74
|
optional bool is_temporary = 7;
|
74
75
|
optional int32 expire_seconds = 8;
|
76
|
+
optional bool keep_original_filename = 9; // 保留原始文件名,默认false
|
75
77
|
}
|
76
78
|
|
77
79
|
message UploadCompletedRequest {
|
@@ -179,6 +181,7 @@ message DownloadUrlInfo {
|
|
179
181
|
|
180
182
|
message GetGcsUrlResponse {
|
181
183
|
string gcs_url = 1;
|
184
|
+
string mime_type = 2;
|
182
185
|
}
|
183
186
|
|
184
187
|
message BatchGetGcsUrlResponse {
|
@@ -188,7 +191,8 @@ message BatchGetGcsUrlResponse {
|
|
188
191
|
message GcsUrlInfo {
|
189
192
|
string file_id = 1;
|
190
193
|
string gcs_url = 2;
|
191
|
-
|
194
|
+
string mime_type = 3;
|
195
|
+
optional string error = 4;
|
192
196
|
}
|
193
197
|
|
194
198
|
message Empty {}
|
@@ -14,6 +14,7 @@ from .file import (
|
|
14
14
|
DownloadUrlInfo,
|
15
15
|
BatchDownloadUrlResponse,
|
16
16
|
GcsUrlInfo,
|
17
|
+
GetGcsUrlResponse,
|
17
18
|
BatchGcsUrlResponse,
|
18
19
|
)
|
19
20
|
from .folder import (
|
@@ -70,6 +71,7 @@ __all__ = [
|
|
70
71
|
"DownloadUrlInfo",
|
71
72
|
"BatchDownloadUrlResponse",
|
72
73
|
"GcsUrlInfo",
|
74
|
+
"GetGcsUrlResponse",
|
73
75
|
"BatchGcsUrlResponse",
|
74
76
|
|
75
77
|
# 文件夹相关
|
file_hub_client/schemas/file.py
CHANGED
@@ -111,9 +111,16 @@ class GcsUrlInfo(BaseModel):
|
|
111
111
|
"""GCS URL信息"""
|
112
112
|
file_id: str = Field(..., description="文件ID")
|
113
113
|
gcs_url: str = Field(..., description="GCS URL")
|
114
|
+
mime_type: str = Field(..., description="MIME类型")
|
114
115
|
error: Optional[str] = Field(None, description="错误信息")
|
115
116
|
|
116
117
|
|
118
|
+
class GetGcsUrlResponse(BaseModel):
|
119
|
+
"""获取GCS URL响应"""
|
120
|
+
gcs_url: str = Field(..., description="GCS URL")
|
121
|
+
mime_type: str = Field(..., description="MIME类型")
|
122
|
+
|
123
|
+
|
117
124
|
class BatchGcsUrlResponse(BaseModel):
|
118
125
|
"""批量GCS URL响应"""
|
119
126
|
gcs_urls: List[GcsUrlInfo] = Field(default_factory=list, description="GCS URL列表")
|
@@ -11,7 +11,7 @@ from .base_file_service import BaseFileService
|
|
11
11
|
from ...enums import UploadMode
|
12
12
|
from ...errors import ValidationError
|
13
13
|
from ...rpc import AsyncGrpcClient
|
14
|
-
from ...schemas import FileUploadResponse, UploadUrlResponse, BatchDownloadUrlResponse, DownloadUrlInfo, GcsUrlInfo, BatchGcsUrlResponse
|
14
|
+
from ...schemas import FileUploadResponse, UploadUrlResponse, BatchDownloadUrlResponse, DownloadUrlInfo, GcsUrlInfo, GetGcsUrlResponse, BatchGcsUrlResponse
|
15
15
|
from ...utils import AsyncHttpUploader, AsyncHttpDownloader, retry_with_backoff, get_file_mime_type
|
16
16
|
|
17
17
|
|
@@ -39,6 +39,7 @@ class AsyncBlobService(BaseFileService):
|
|
39
39
|
mime_type: Optional[str] = None,
|
40
40
|
is_temporary: Optional[bool] = False,
|
41
41
|
expire_seconds: Optional[int] = None,
|
42
|
+
keep_original_filename: Optional[bool] = False,
|
42
43
|
request_id: Optional[str] = None,
|
43
44
|
**metadata
|
44
45
|
) -> FileUploadResponse:
|
@@ -53,6 +54,7 @@ class AsyncBlobService(BaseFileService):
|
|
53
54
|
mime_type: MIME类型
|
54
55
|
is_temporary: 是否为临时文件
|
55
56
|
expire_seconds: 过期秒数
|
57
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
56
58
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
57
59
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
58
60
|
|
@@ -86,6 +88,7 @@ class AsyncBlobService(BaseFileService):
|
|
86
88
|
mime_type=mime_type or "application/octet-stream",
|
87
89
|
is_temporary=is_temporary,
|
88
90
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
91
|
+
keep_original_filename=keep_original_filename,
|
89
92
|
)
|
90
93
|
|
91
94
|
if folder_id:
|
@@ -114,6 +117,7 @@ class AsyncBlobService(BaseFileService):
|
|
114
117
|
file_hash: str,
|
115
118
|
is_temporary: Optional[bool] = False,
|
116
119
|
expire_seconds: Optional[int] = None,
|
120
|
+
keep_original_filename: Optional[bool] = False,
|
117
121
|
request_id: Optional[str] = None,
|
118
122
|
**metadata
|
119
123
|
) -> FileUploadResponse:
|
@@ -129,6 +133,7 @@ class AsyncBlobService(BaseFileService):
|
|
129
133
|
file_hash=file_hash,
|
130
134
|
is_temporary=is_temporary,
|
131
135
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
136
|
+
keep_original_filename=keep_original_filename,
|
132
137
|
request_id=request_id,
|
133
138
|
**metadata
|
134
139
|
)
|
@@ -172,6 +177,7 @@ class AsyncBlobService(BaseFileService):
|
|
172
177
|
file_hash: str,
|
173
178
|
is_temporary: Optional[bool] = False,
|
174
179
|
expire_seconds: Optional[int] = None,
|
180
|
+
keep_original_filename: Optional[bool] = False,
|
175
181
|
request_id: Optional[str] = None,
|
176
182
|
**metadata
|
177
183
|
) -> FileUploadResponse:
|
@@ -186,6 +192,7 @@ class AsyncBlobService(BaseFileService):
|
|
186
192
|
file_hash=file_hash,
|
187
193
|
is_temporary=is_temporary,
|
188
194
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
195
|
+
keep_original_filename=keep_original_filename,
|
189
196
|
request_id=request_id,
|
190
197
|
**metadata
|
191
198
|
)
|
@@ -256,6 +263,7 @@ class AsyncBlobService(BaseFileService):
|
|
256
263
|
file_hash: Optional[str] = None,
|
257
264
|
is_temporary: Optional[bool] = False,
|
258
265
|
expire_seconds: Optional[int] = None,
|
266
|
+
keep_original_filename: Optional[bool] = False,
|
259
267
|
request_id: Optional[str] = None,
|
260
268
|
**metadata
|
261
269
|
) -> UploadUrlResponse:
|
@@ -271,6 +279,8 @@ class AsyncBlobService(BaseFileService):
|
|
271
279
|
file_hash: 文件哈希
|
272
280
|
is_temporary: 是否为临时文件
|
273
281
|
expire_seconds: 过期秒数
|
282
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
283
|
+
request_id: 请求ID(可选,如果不提供则自动生成)
|
274
284
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
275
285
|
|
276
286
|
Returns:
|
@@ -288,6 +298,7 @@ class AsyncBlobService(BaseFileService):
|
|
288
298
|
file_hash=file_hash,
|
289
299
|
is_temporary=is_temporary,
|
290
300
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
301
|
+
keep_original_filename=keep_original_filename,
|
291
302
|
)
|
292
303
|
|
293
304
|
if folder_id:
|
@@ -314,6 +325,7 @@ class AsyncBlobService(BaseFileService):
|
|
314
325
|
file_hash: str = None,
|
315
326
|
is_temporary: Optional[bool] = False,
|
316
327
|
expire_seconds: Optional[int] = None,
|
328
|
+
keep_original_filename: Optional[bool] = False,
|
317
329
|
request_id: Optional[str] = None,
|
318
330
|
**metadata
|
319
331
|
) -> UploadUrlResponse:
|
@@ -329,6 +341,7 @@ class AsyncBlobService(BaseFileService):
|
|
329
341
|
file_hash: 文件哈希
|
330
342
|
is_temporary: 是否为临时文件
|
331
343
|
expire_seconds: 过期秒数
|
344
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
332
345
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
333
346
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
334
347
|
|
@@ -349,6 +362,7 @@ class AsyncBlobService(BaseFileService):
|
|
349
362
|
file_hash=file_hash,
|
350
363
|
is_temporary=is_temporary,
|
351
364
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
365
|
+
keep_original_filename=keep_original_filename,
|
352
366
|
)
|
353
367
|
|
354
368
|
if folder_id:
|
@@ -373,6 +387,7 @@ class AsyncBlobService(BaseFileService):
|
|
373
387
|
mode: Optional[UploadMode] = UploadMode.NORMAL,
|
374
388
|
is_temporary: Optional[bool] = False,
|
375
389
|
expire_seconds: Optional[int] = None,
|
390
|
+
keep_original_filename: Optional[bool] = False,
|
376
391
|
url: Optional[str] = None,
|
377
392
|
file_name: Optional[str] = None,
|
378
393
|
request_id: Optional[str] = None,
|
@@ -387,6 +402,7 @@ class AsyncBlobService(BaseFileService):
|
|
387
402
|
mode: 上传模式(NORMAL/DIRECT/RESUMABLE/STREAM)
|
388
403
|
is_temporary: 是否为临时文件
|
389
404
|
expire_seconds: 过期秒数
|
405
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
390
406
|
url: 要下载并上传的URL(可选)
|
391
407
|
file_name: 当使用url参数时指定的文件名(可选)
|
392
408
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
@@ -461,6 +477,7 @@ class AsyncBlobService(BaseFileService):
|
|
461
477
|
mime_type=mime_type,
|
462
478
|
is_temporary=is_temporary,
|
463
479
|
expire_seconds=expire_seconds,
|
480
|
+
keep_original_filename=keep_original_filename,
|
464
481
|
request_id=request_id,
|
465
482
|
**metadata
|
466
483
|
)
|
@@ -477,6 +494,7 @@ class AsyncBlobService(BaseFileService):
|
|
477
494
|
file_hash=file_hash,
|
478
495
|
is_temporary=is_temporary,
|
479
496
|
expire_seconds=expire_seconds,
|
497
|
+
keep_original_filename=keep_original_filename,
|
480
498
|
request_id=request_id,
|
481
499
|
**metadata
|
482
500
|
)
|
@@ -493,6 +511,7 @@ class AsyncBlobService(BaseFileService):
|
|
493
511
|
file_hash=file_hash,
|
494
512
|
is_temporary=is_temporary,
|
495
513
|
expire_seconds=expire_seconds,
|
514
|
+
keep_original_filename=keep_original_filename,
|
496
515
|
request_id=request_id,
|
497
516
|
**metadata
|
498
517
|
)
|
@@ -623,7 +642,7 @@ class AsyncBlobService(BaseFileService):
|
|
623
642
|
*,
|
624
643
|
request_id: Optional[str] = None,
|
625
644
|
**metadata
|
626
|
-
) ->
|
645
|
+
) -> GetGcsUrlResponse:
|
627
646
|
"""
|
628
647
|
获取文件的GCS URL
|
629
648
|
|
@@ -633,7 +652,7 @@ class AsyncBlobService(BaseFileService):
|
|
633
652
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
634
653
|
|
635
654
|
Returns:
|
636
|
-
GCS URL
|
655
|
+
GCS URL响应,包含URL和MIME类型
|
637
656
|
"""
|
638
657
|
from ...rpc.gen import file_service_pb2, file_service_pb2_grpc
|
639
658
|
|
@@ -646,7 +665,10 @@ class AsyncBlobService(BaseFileService):
|
|
646
665
|
|
647
666
|
response = await stub.GetGcsUrl(request, metadata=grpc_metadata)
|
648
667
|
|
649
|
-
return
|
668
|
+
return GetGcsUrlResponse(
|
669
|
+
gcs_url=response.gcs_url,
|
670
|
+
mime_type=response.mime_type
|
671
|
+
)
|
650
672
|
|
651
673
|
async def batch_get_gcs_url(
|
652
674
|
self,
|
@@ -683,6 +705,7 @@ class AsyncBlobService(BaseFileService):
|
|
683
705
|
gcs_urls.append(GcsUrlInfo(
|
684
706
|
file_id=url_info.file_id,
|
685
707
|
gcs_url=url_info.gcs_url,
|
708
|
+
mime_type=url_info.mime_type,
|
686
709
|
error=url_info.error if url_info.HasField('error') else None
|
687
710
|
))
|
688
711
|
|
@@ -9,7 +9,7 @@ from .base_file_service import BaseFileService
|
|
9
9
|
from ...enums import UploadMode
|
10
10
|
from ...errors import ValidationError
|
11
11
|
from ...rpc import SyncGrpcClient
|
12
|
-
from ...schemas import FileUploadResponse, UploadUrlResponse, BatchDownloadUrlResponse, DownloadUrlInfo, GcsUrlInfo, BatchGcsUrlResponse
|
12
|
+
from ...schemas import FileUploadResponse, UploadUrlResponse, BatchDownloadUrlResponse, DownloadUrlInfo, GcsUrlInfo, GetGcsUrlResponse, BatchGcsUrlResponse
|
13
13
|
from ...utils import HttpUploader, HttpDownloader, retry_with_backoff, get_file_mime_type
|
14
14
|
|
15
15
|
|
@@ -37,6 +37,7 @@ class SyncBlobService(BaseFileService):
|
|
37
37
|
mime_type: Optional[str] = None,
|
38
38
|
is_temporary: Optional[bool] = False,
|
39
39
|
expire_seconds: Optional[int] = None,
|
40
|
+
keep_original_filename: Optional[bool] = False,
|
40
41
|
request_id: Optional[str] = None,
|
41
42
|
**metadata
|
42
43
|
) -> FileUploadResponse:
|
@@ -51,6 +52,7 @@ class SyncBlobService(BaseFileService):
|
|
51
52
|
mime_type: MIME类型
|
52
53
|
is_temporary: 是否为临时文件
|
53
54
|
expire_seconds: 过期秒数
|
55
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
54
56
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
55
57
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
56
58
|
|
@@ -84,6 +86,7 @@ class SyncBlobService(BaseFileService):
|
|
84
86
|
mime_type=mime_type or "application/octet-stream",
|
85
87
|
is_temporary=is_temporary,
|
86
88
|
expire_seconds=expire_seconds,
|
89
|
+
keep_original_filename=keep_original_filename,
|
87
90
|
)
|
88
91
|
|
89
92
|
if folder_id:
|
@@ -112,6 +115,7 @@ class SyncBlobService(BaseFileService):
|
|
112
115
|
file_hash: str,
|
113
116
|
is_temporary: Optional[bool] = False,
|
114
117
|
expire_seconds: Optional[int] = None,
|
118
|
+
keep_original_filename: Optional[bool] = False,
|
115
119
|
request_id: Optional[str] = None,
|
116
120
|
**metadata
|
117
121
|
) -> FileUploadResponse:
|
@@ -126,6 +130,7 @@ class SyncBlobService(BaseFileService):
|
|
126
130
|
file_hash=file_hash,
|
127
131
|
is_temporary=is_temporary,
|
128
132
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
133
|
+
keep_original_filename=keep_original_filename,
|
129
134
|
request_id=request_id,
|
130
135
|
**metadata
|
131
136
|
)
|
@@ -169,6 +174,7 @@ class SyncBlobService(BaseFileService):
|
|
169
174
|
file_hash: str,
|
170
175
|
is_temporary: Optional[bool] = False,
|
171
176
|
expire_seconds: Optional[int] = None,
|
177
|
+
keep_original_filename: Optional[bool] = False,
|
172
178
|
request_id: Optional[str] = None,
|
173
179
|
**metadata
|
174
180
|
) -> FileUploadResponse:
|
@@ -183,6 +189,7 @@ class SyncBlobService(BaseFileService):
|
|
183
189
|
file_hash=file_hash,
|
184
190
|
is_temporary=is_temporary,
|
185
191
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
192
|
+
keep_original_filename=keep_original_filename,
|
186
193
|
request_id=request_id,
|
187
194
|
**metadata
|
188
195
|
)
|
@@ -254,6 +261,7 @@ class SyncBlobService(BaseFileService):
|
|
254
261
|
file_hash: str = None,
|
255
262
|
is_temporary: Optional[bool] = False,
|
256
263
|
expire_seconds: Optional[int] = None,
|
264
|
+
keep_original_filename: Optional[bool] = False,
|
257
265
|
request_id: Optional[str] = None,
|
258
266
|
**metadata
|
259
267
|
) -> UploadUrlResponse:
|
@@ -269,6 +277,8 @@ class SyncBlobService(BaseFileService):
|
|
269
277
|
file_hash: 文件哈希
|
270
278
|
is_temporary: 是否为临时文件
|
271
279
|
expire_seconds: 过期秒数
|
280
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
281
|
+
request_id: 请求ID(可选,如果不提供则自动生成)
|
272
282
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
273
283
|
|
274
284
|
Returns:
|
@@ -286,6 +296,7 @@ class SyncBlobService(BaseFileService):
|
|
286
296
|
file_hash=file_hash,
|
287
297
|
is_temporary=is_temporary,
|
288
298
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
299
|
+
keep_original_filename=keep_original_filename,
|
289
300
|
)
|
290
301
|
|
291
302
|
if folder_id:
|
@@ -312,6 +323,7 @@ class SyncBlobService(BaseFileService):
|
|
312
323
|
file_hash: str = None,
|
313
324
|
is_temporary: Optional[bool] = False,
|
314
325
|
expire_seconds: Optional[int] = None,
|
326
|
+
keep_original_filename: Optional[bool] = False,
|
315
327
|
request_id: Optional[str] = None,
|
316
328
|
**metadata
|
317
329
|
) -> UploadUrlResponse:
|
@@ -327,6 +339,7 @@ class SyncBlobService(BaseFileService):
|
|
327
339
|
file_hash: 文件哈希
|
328
340
|
is_temporary: 是否为临时文件
|
329
341
|
expire_seconds: 过期秒数
|
342
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
330
343
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
331
344
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
332
345
|
|
@@ -347,6 +360,7 @@ class SyncBlobService(BaseFileService):
|
|
347
360
|
file_hash=file_hash,
|
348
361
|
is_temporary=is_temporary,
|
349
362
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
363
|
+
keep_original_filename=keep_original_filename,
|
350
364
|
)
|
351
365
|
|
352
366
|
if folder_id:
|
@@ -371,6 +385,7 @@ class SyncBlobService(BaseFileService):
|
|
371
385
|
mode: Optional[UploadMode] = UploadMode.NORMAL,
|
372
386
|
is_temporary: Optional[bool] = False,
|
373
387
|
expire_seconds: Optional[int] = None,
|
388
|
+
keep_original_filename: Optional[bool] = False,
|
374
389
|
url: Optional[str] = None,
|
375
390
|
file_name: Optional[str] = None,
|
376
391
|
request_id: Optional[str] = None,
|
@@ -385,6 +400,7 @@ class SyncBlobService(BaseFileService):
|
|
385
400
|
mode: 上传模式(NORMAL/DIRECT/RESUMABLE/STREAM)
|
386
401
|
is_temporary: 是否为临时文件
|
387
402
|
expire_seconds: 过期秒数
|
403
|
+
keep_original_filename: 是否保留原始文件名(默认False)
|
388
404
|
url: 要下载并上传的URL(可选)
|
389
405
|
file_name: 当使用url参数时指定的文件名(可选)
|
390
406
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
@@ -459,6 +475,7 @@ class SyncBlobService(BaseFileService):
|
|
459
475
|
mime_type=mime_type,
|
460
476
|
is_temporary=is_temporary,
|
461
477
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
478
|
+
keep_original_filename=keep_original_filename,
|
462
479
|
request_id=request_id,
|
463
480
|
**metadata
|
464
481
|
)
|
@@ -475,6 +492,7 @@ class SyncBlobService(BaseFileService):
|
|
475
492
|
file_hash=file_hash,
|
476
493
|
is_temporary=is_temporary,
|
477
494
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
495
|
+
keep_original_filename=keep_original_filename,
|
478
496
|
request_id=request_id,
|
479
497
|
**metadata
|
480
498
|
)
|
@@ -491,6 +509,7 @@ class SyncBlobService(BaseFileService):
|
|
491
509
|
file_hash=file_hash,
|
492
510
|
is_temporary=is_temporary,
|
493
511
|
expire_seconds=expire_seconds if is_temporary and expire_seconds else None,
|
512
|
+
keep_original_filename=keep_original_filename,
|
494
513
|
request_id=request_id,
|
495
514
|
**metadata
|
496
515
|
)
|
@@ -620,7 +639,7 @@ class SyncBlobService(BaseFileService):
|
|
620
639
|
*,
|
621
640
|
request_id: Optional[str] = None,
|
622
641
|
**metadata
|
623
|
-
) ->
|
642
|
+
) -> GetGcsUrlResponse:
|
624
643
|
"""
|
625
644
|
获取文件的GCS URL
|
626
645
|
|
@@ -630,7 +649,7 @@ class SyncBlobService(BaseFileService):
|
|
630
649
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
631
650
|
|
632
651
|
Returns:
|
633
|
-
GCS URL
|
652
|
+
GCS URL响应,包含URL和MIME类型
|
634
653
|
"""
|
635
654
|
from ...rpc.gen import file_service_pb2, file_service_pb2_grpc
|
636
655
|
|
@@ -643,7 +662,10 @@ class SyncBlobService(BaseFileService):
|
|
643
662
|
|
644
663
|
response = stub.GetGcsUrl(request, metadata=grpc_metadata)
|
645
664
|
|
646
|
-
return
|
665
|
+
return GetGcsUrlResponse(
|
666
|
+
gcs_url=response.gcs_url,
|
667
|
+
mime_type=response.mime_type
|
668
|
+
)
|
647
669
|
|
648
670
|
def batch_get_gcs_url(
|
649
671
|
self,
|
@@ -680,6 +702,7 @@ class SyncBlobService(BaseFileService):
|
|
680
702
|
gcs_urls.append(GcsUrlInfo(
|
681
703
|
file_id=url_info.file_id,
|
682
704
|
gcs_url=url_info.gcs_url,
|
705
|
+
mime_type=url_info.mime_type,
|
683
706
|
error=url_info.error if url_info.HasField('error') else None
|
684
707
|
))
|
685
708
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: tamar-file-hub-client
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.3
|
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
|
@@ -641,6 +641,30 @@ async with AsyncTamarFileHubClient() as client:
|
|
641
641
|
)
|
642
642
|
```
|
643
643
|
|
644
|
+
#### 保留原始文件名上传
|
645
|
+
|
646
|
+
```python
|
647
|
+
from file_hub_client import AsyncTamarFileHubClient
|
648
|
+
|
649
|
+
async with AsyncTamarFileHubClient() as client:
|
650
|
+
# 设置用户上下文
|
651
|
+
client.set_user_context(org_id="123", user_id="456")
|
652
|
+
|
653
|
+
# 上传时保留原始文件名
|
654
|
+
file_info = await client.blobs.upload(
|
655
|
+
"document.pdf",
|
656
|
+
keep_original_filename=True # 保留原始文件名,默认为False
|
657
|
+
)
|
658
|
+
|
659
|
+
# 也可以指定文件夹和其他参数
|
660
|
+
file_info = await client.blobs.upload(
|
661
|
+
"report.xlsx",
|
662
|
+
folder_id="folder-123",
|
663
|
+
keep_original_filename=True, # 保留原始文件名
|
664
|
+
is_temporary=False
|
665
|
+
)
|
666
|
+
```
|
667
|
+
|
644
668
|
### 文件下载
|
645
669
|
|
646
670
|
File Hub Client 提供了统一的下载接口,支持两种结构返回:
|
@@ -682,6 +706,137 @@ async with AsyncTamarFileHubClient() as client:
|
|
682
706
|
print(f"文件已保存到: {save_path}")
|
683
707
|
```
|
684
708
|
|
709
|
+
#### 高级下载功能
|
710
|
+
|
711
|
+
File Hub Client 提供了高级的下载URL管理功能,支持批量操作和直接获取GCS URL:
|
712
|
+
|
713
|
+
##### 批量生成下载URL
|
714
|
+
|
715
|
+
当需要为多个文件生成下载URL时,使用批量接口可以显著提高效率:
|
716
|
+
|
717
|
+
```python
|
718
|
+
from file_hub_client import AsyncTamarFileHubClient
|
719
|
+
|
720
|
+
async with AsyncTamarFileHubClient() as client:
|
721
|
+
# 设置用户上下文
|
722
|
+
client.set_user_context(org_id="123", user_id="456")
|
723
|
+
|
724
|
+
# 批量生成下载URL
|
725
|
+
file_ids = ["file-001", "file-002", "file-003"]
|
726
|
+
|
727
|
+
result = await client.blobs.batch_generate_download_url(
|
728
|
+
file_ids=file_ids,
|
729
|
+
is_cdn=True, # 使用CDN加速(可选,默认为True)
|
730
|
+
expire_seconds=3600 # URL有效期1小时(可选)
|
731
|
+
)
|
732
|
+
|
733
|
+
# 处理结果
|
734
|
+
for url_info in result.download_urls:
|
735
|
+
if url_info.error:
|
736
|
+
print(f"文件 {url_info.file_id} 生成URL失败: {url_info.error}")
|
737
|
+
else:
|
738
|
+
print(f"文件 {url_info.file_id} 的下载URL: {url_info.url}")
|
739
|
+
```
|
740
|
+
|
741
|
+
同步客户端示例:
|
742
|
+
|
743
|
+
```python
|
744
|
+
from file_hub_client import TamarFileHubClient
|
745
|
+
|
746
|
+
with TamarFileHubClient() as client:
|
747
|
+
client.set_user_context(org_id="123", user_id="456")
|
748
|
+
|
749
|
+
result = client.blobs.batch_generate_download_url(
|
750
|
+
file_ids=["file-001", "file-002"],
|
751
|
+
is_cdn=False # 不使用CDN,直接返回源站URL
|
752
|
+
)
|
753
|
+
```
|
754
|
+
|
755
|
+
##### 获取GCS URL
|
756
|
+
|
757
|
+
对于需要直接访问Google Cloud Storage的场景,可以获取文件的GCS URL和MIME类型信息:
|
758
|
+
|
759
|
+
```python
|
760
|
+
# 异步客户端 - 获取单个文件的GCS URL
|
761
|
+
async with AsyncTamarFileHubClient() as client:
|
762
|
+
client.set_user_context(org_id="123", user_id="456")
|
763
|
+
|
764
|
+
gcs_response = await client.blobs.get_gcs_url(file_id="file-001")
|
765
|
+
print(f"GCS URL: {gcs_response.gcs_url}")
|
766
|
+
print(f"MIME类型: {gcs_response.mime_type}")
|
767
|
+
# 输出示例:
|
768
|
+
# GCS URL: gs://bucket-name/path/to/file.pdf
|
769
|
+
# MIME类型: application/pdf
|
770
|
+
```
|
771
|
+
|
772
|
+
**注意**:`get_gcs_url` 方法现在返回一个 `GetGcsUrlResponse` 对象,包含:
|
773
|
+
- `gcs_url`: Google Cloud Storage 的完整路径
|
774
|
+
- `mime_type`: 文件的MIME类型,便于正确处理文件内容
|
775
|
+
|
776
|
+
##### 批量获取GCS URL
|
777
|
+
|
778
|
+
批量获取多个文件的GCS URL和MIME类型信息:
|
779
|
+
|
780
|
+
```python
|
781
|
+
# 异步客户端 - 批量获取GCS URL
|
782
|
+
async with AsyncTamarFileHubClient() as client:
|
783
|
+
client.set_user_context(org_id="123", user_id="456")
|
784
|
+
|
785
|
+
file_ids = ["file-001", "file-002", "file-003"]
|
786
|
+
result = await client.blobs.batch_get_gcs_url(file_ids)
|
787
|
+
|
788
|
+
# 处理结果
|
789
|
+
for url_info in result.gcs_urls:
|
790
|
+
if url_info.error:
|
791
|
+
print(f"文件 {url_info.file_id} 获取GCS URL失败: {url_info.error}")
|
792
|
+
else:
|
793
|
+
print(f"文件 {url_info.file_id}:")
|
794
|
+
print(f" GCS URL: {url_info.gcs_url}")
|
795
|
+
print(f" MIME类型: {url_info.mime_type}")
|
796
|
+
# 根据MIME类型处理文件
|
797
|
+
if url_info.mime_type.startswith('image/'):
|
798
|
+
print(f" 这是一个图片文件")
|
799
|
+
elif url_info.mime_type == 'application/pdf':
|
800
|
+
print(f" 这是一个PDF文件")
|
801
|
+
```
|
802
|
+
|
803
|
+
同步客户端示例:
|
804
|
+
|
805
|
+
```python
|
806
|
+
# 同步客户端 - 批量获取GCS URL
|
807
|
+
with TamarFileHubClient() as client:
|
808
|
+
client.set_user_context(org_id="123", user_id="456")
|
809
|
+
|
810
|
+
# 获取单个GCS URL
|
811
|
+
gcs_response = client.blobs.get_gcs_url(file_id="file-001")
|
812
|
+
print(f"GCS URL: {gcs_response.gcs_url}")
|
813
|
+
print(f"MIME类型: {gcs_response.mime_type}")
|
814
|
+
|
815
|
+
# 批量获取GCS URL
|
816
|
+
result = client.blobs.batch_get_gcs_url(["file-001", "file-002"])
|
817
|
+
```
|
818
|
+
|
819
|
+
##### 使用场景说明
|
820
|
+
|
821
|
+
1. **批量下载URL生成**:
|
822
|
+
- 适用于需要同时下载多个文件的场景
|
823
|
+
- 支持CDN加速,提供更好的下载体验
|
824
|
+
- 可设置URL有效期,增强安全性
|
825
|
+
- 批量操作减少网络往返,提高效率
|
826
|
+
|
827
|
+
2. **GCS URL获取**:
|
828
|
+
- 适用于需要与Google Cloud服务集成的场景
|
829
|
+
- 可用于数据分析、批处理等后端处理
|
830
|
+
- 支持使用GCS工具进行文件操作
|
831
|
+
- 返回的是永久有效的存储路径
|
832
|
+
- 同时返回MIME类型信息,便于正确处理不同类型的文件
|
833
|
+
- 可根据MIME类型选择合适的处理方式(如图片处理、文档解析等)
|
834
|
+
|
835
|
+
3. **错误处理**:
|
836
|
+
- 每个文件独立处理,部分失败不影响其他文件
|
837
|
+
- 错误信息通过 `error` 字段返回
|
838
|
+
- 建议在批量操作时做好错误处理和重试逻辑
|
839
|
+
|
685
840
|
### 文件管理操作
|
686
841
|
|
687
842
|
File Hub Client 提供了完整的文件管理功能,通过 `files` 服务访问:
|
@@ -2019,6 +2174,13 @@ MIT License
|
|
2019
2174
|
|
2020
2175
|
## 更新日志
|
2021
2176
|
|
2177
|
+
### v0.0.5 (2025-01)
|
2178
|
+
- 新增批量下载URL生成接口 (batch_generate_download_url)
|
2179
|
+
- 新增GCS URL获取接口 (get_gcs_url, batch_get_gcs_url)
|
2180
|
+
- GCS URL接口返回MIME类型信息,便于文件类型识别
|
2181
|
+
- 新增 keep_original_filename 参数支持保留原始文件名
|
2182
|
+
- 更新相关文档和测试用例
|
2183
|
+
|
2022
2184
|
### v0.0.4 (2025-01)
|
2023
2185
|
- 新增从URL上传文件功能
|
2024
2186
|
- 支持自动下载URL内容并上传到GCS
|
@@ -13,26 +13,26 @@ 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=
|
16
|
+
file_hub_client/rpc/gen/file_service_pb2.py,sha256=KphiN6KuksPPDP-PKuTo1COKTAO0M1XsCm0as2BC2Qc,11211
|
17
17
|
file_hub_client/rpc/gen/file_service_pb2_grpc.py,sha256=F7u-n6doSz1HxmaYAL0y_nNB1NVR8CRlZVKAMe63P4A,26083
|
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=fekeTjDP_qaWL8EPVblH2EV_7xnWVTZgoIX7sAUNZ8Y,4995
|
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=9BvyqWBkeEav47vUBZ6eDyCt_iKATCOwakcrmOTdVWA,2396
|
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=s4_gYriOn_UP9gcDRqB2YNvNN-FqEZEbfJCOVE5JUTQ,4899
|
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
|
-
file_hub_client/services/file/async_blob_service.py,sha256=
|
32
|
+
file_hub_client/services/file/async_blob_service.py,sha256=qOUFvkNyjDsFHNpLpjqIB0z5xF2KkFlgpa3HblEPXYg,25962
|
33
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
|
-
file_hub_client/services/file/sync_blob_service.py,sha256=
|
35
|
+
file_hub_client/services/file/sync_blob_service.py,sha256=IcbXzyoZHNHzE3aDZ69M5AOqJk4-mR0w0TKyohjEGHQ,25689
|
36
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
|
@@ -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.1.
|
55
|
-
tamar_file_hub_client-0.1.
|
56
|
-
tamar_file_hub_client-0.1.
|
57
|
-
tamar_file_hub_client-0.1.
|
54
|
+
tamar_file_hub_client-0.1.3.dist-info/METADATA,sha256=t8Ohoetv3OYCeon2R4G8WivDCQloG_kXLCTntdszx2o,71188
|
55
|
+
tamar_file_hub_client-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
56
|
+
tamar_file_hub_client-0.1.3.dist-info/top_level.txt,sha256=9wcR7hyAJQdJg_kuH6WR3nmpJ8O-j8aJNK8f_kcFy6U,16
|
57
|
+
tamar_file_hub_client-0.1.3.dist-info/RECORD,,
|
File without changes
|
{tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.3.dist-info}/top_level.txt
RENAMED
File without changes
|