tamar-file-hub-client 0.1.1__py3-none-any.whl → 0.1.2__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 +10 -10
- file_hub_client/rpc/protos/file_service.proto +3 -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 +8 -4
- file_hub_client/services/file/sync_blob_service.py +8 -4
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.2.dist-info}/METADATA +138 -1
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.2.dist-info}/RECORD +10 -10
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.2.dist-info}/WHEEL +0 -0
- {tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.2.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\"{\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\"
|
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\"{\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)
|
@@ -80,13 +80,13 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
80
80
|
_globals['_DOWNLOADURLINFO']._serialized_start=2659
|
81
81
|
_globals['_DOWNLOADURLINFO']._serialized_end=2736
|
82
82
|
_globals['_GETGCSURLRESPONSE']._serialized_start=2738
|
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=
|
83
|
+
_globals['_GETGCSURLRESPONSE']._serialized_end=2793
|
84
|
+
_globals['_BATCHGETGCSURLRESPONSE']._serialized_start=2795
|
85
|
+
_globals['_BATCHGETGCSURLRESPONSE']._serialized_end=2855
|
86
|
+
_globals['_GCSURLINFO']._serialized_start=2857
|
87
|
+
_globals['_GCSURLINFO']._serialized_end=2952
|
88
|
+
_globals['_EMPTY']._serialized_start=2954
|
89
|
+
_globals['_EMPTY']._serialized_end=2961
|
90
|
+
_globals['_FILESERVICE']._serialized_start=2964
|
91
|
+
_globals['_FILESERVICE']._serialized_end=3906
|
92
92
|
# @@protoc_insertion_point(module_scope)
|
@@ -179,6 +179,7 @@ message DownloadUrlInfo {
|
|
179
179
|
|
180
180
|
message GetGcsUrlResponse {
|
181
181
|
string gcs_url = 1;
|
182
|
+
string mime_type = 2;
|
182
183
|
}
|
183
184
|
|
184
185
|
message BatchGetGcsUrlResponse {
|
@@ -188,7 +189,8 @@ message BatchGetGcsUrlResponse {
|
|
188
189
|
message GcsUrlInfo {
|
189
190
|
string file_id = 1;
|
190
191
|
string gcs_url = 2;
|
191
|
-
|
192
|
+
string mime_type = 3;
|
193
|
+
optional string error = 4;
|
192
194
|
}
|
193
195
|
|
194
196
|
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
|
|
@@ -623,7 +623,7 @@ class AsyncBlobService(BaseFileService):
|
|
623
623
|
*,
|
624
624
|
request_id: Optional[str] = None,
|
625
625
|
**metadata
|
626
|
-
) ->
|
626
|
+
) -> GetGcsUrlResponse:
|
627
627
|
"""
|
628
628
|
获取文件的GCS URL
|
629
629
|
|
@@ -633,7 +633,7 @@ class AsyncBlobService(BaseFileService):
|
|
633
633
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
634
634
|
|
635
635
|
Returns:
|
636
|
-
GCS URL
|
636
|
+
GCS URL响应,包含URL和MIME类型
|
637
637
|
"""
|
638
638
|
from ...rpc.gen import file_service_pb2, file_service_pb2_grpc
|
639
639
|
|
@@ -646,7 +646,10 @@ class AsyncBlobService(BaseFileService):
|
|
646
646
|
|
647
647
|
response = await stub.GetGcsUrl(request, metadata=grpc_metadata)
|
648
648
|
|
649
|
-
return
|
649
|
+
return GetGcsUrlResponse(
|
650
|
+
gcs_url=response.gcs_url,
|
651
|
+
mime_type=response.mime_type
|
652
|
+
)
|
650
653
|
|
651
654
|
async def batch_get_gcs_url(
|
652
655
|
self,
|
@@ -683,6 +686,7 @@ class AsyncBlobService(BaseFileService):
|
|
683
686
|
gcs_urls.append(GcsUrlInfo(
|
684
687
|
file_id=url_info.file_id,
|
685
688
|
gcs_url=url_info.gcs_url,
|
689
|
+
mime_type=url_info.mime_type,
|
686
690
|
error=url_info.error if url_info.HasField('error') else None
|
687
691
|
))
|
688
692
|
|
@@ -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
|
|
@@ -620,7 +620,7 @@ class SyncBlobService(BaseFileService):
|
|
620
620
|
*,
|
621
621
|
request_id: Optional[str] = None,
|
622
622
|
**metadata
|
623
|
-
) ->
|
623
|
+
) -> GetGcsUrlResponse:
|
624
624
|
"""
|
625
625
|
获取文件的GCS URL
|
626
626
|
|
@@ -630,7 +630,7 @@ class SyncBlobService(BaseFileService):
|
|
630
630
|
**metadata: 额外的元数据(如 x-org-id, x-user-id 等)
|
631
631
|
|
632
632
|
Returns:
|
633
|
-
GCS URL
|
633
|
+
GCS URL响应,包含URL和MIME类型
|
634
634
|
"""
|
635
635
|
from ...rpc.gen import file_service_pb2, file_service_pb2_grpc
|
636
636
|
|
@@ -643,7 +643,10 @@ class SyncBlobService(BaseFileService):
|
|
643
643
|
|
644
644
|
response = stub.GetGcsUrl(request, metadata=grpc_metadata)
|
645
645
|
|
646
|
-
return
|
646
|
+
return GetGcsUrlResponse(
|
647
|
+
gcs_url=response.gcs_url,
|
648
|
+
mime_type=response.mime_type
|
649
|
+
)
|
647
650
|
|
648
651
|
def batch_get_gcs_url(
|
649
652
|
self,
|
@@ -680,6 +683,7 @@ class SyncBlobService(BaseFileService):
|
|
680
683
|
gcs_urls.append(GcsUrlInfo(
|
681
684
|
file_id=url_info.file_id,
|
682
685
|
gcs_url=url_info.gcs_url,
|
686
|
+
mime_type=url_info.mime_type,
|
683
687
|
error=url_info.error if url_info.HasField('error') else None
|
684
688
|
))
|
685
689
|
|
@@ -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.2
|
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
|
@@ -682,6 +682,137 @@ async with AsyncTamarFileHubClient() as client:
|
|
682
682
|
print(f"文件已保存到: {save_path}")
|
683
683
|
```
|
684
684
|
|
685
|
+
#### 高级下载功能
|
686
|
+
|
687
|
+
File Hub Client 提供了高级的下载URL管理功能,支持批量操作和直接获取GCS URL:
|
688
|
+
|
689
|
+
##### 批量生成下载URL
|
690
|
+
|
691
|
+
当需要为多个文件生成下载URL时,使用批量接口可以显著提高效率:
|
692
|
+
|
693
|
+
```python
|
694
|
+
from file_hub_client import AsyncTamarFileHubClient
|
695
|
+
|
696
|
+
async with AsyncTamarFileHubClient() as client:
|
697
|
+
# 设置用户上下文
|
698
|
+
client.set_user_context(org_id="123", user_id="456")
|
699
|
+
|
700
|
+
# 批量生成下载URL
|
701
|
+
file_ids = ["file-001", "file-002", "file-003"]
|
702
|
+
|
703
|
+
result = await client.blobs.batch_generate_download_url(
|
704
|
+
file_ids=file_ids,
|
705
|
+
is_cdn=True, # 使用CDN加速(可选,默认为True)
|
706
|
+
expire_seconds=3600 # URL有效期1小时(可选)
|
707
|
+
)
|
708
|
+
|
709
|
+
# 处理结果
|
710
|
+
for url_info in result.download_urls:
|
711
|
+
if url_info.error:
|
712
|
+
print(f"文件 {url_info.file_id} 生成URL失败: {url_info.error}")
|
713
|
+
else:
|
714
|
+
print(f"文件 {url_info.file_id} 的下载URL: {url_info.url}")
|
715
|
+
```
|
716
|
+
|
717
|
+
同步客户端示例:
|
718
|
+
|
719
|
+
```python
|
720
|
+
from file_hub_client import TamarFileHubClient
|
721
|
+
|
722
|
+
with TamarFileHubClient() as client:
|
723
|
+
client.set_user_context(org_id="123", user_id="456")
|
724
|
+
|
725
|
+
result = client.blobs.batch_generate_download_url(
|
726
|
+
file_ids=["file-001", "file-002"],
|
727
|
+
is_cdn=False # 不使用CDN,直接返回源站URL
|
728
|
+
)
|
729
|
+
```
|
730
|
+
|
731
|
+
##### 获取GCS URL
|
732
|
+
|
733
|
+
对于需要直接访问Google Cloud Storage的场景,可以获取文件的GCS URL和MIME类型信息:
|
734
|
+
|
735
|
+
```python
|
736
|
+
# 异步客户端 - 获取单个文件的GCS URL
|
737
|
+
async with AsyncTamarFileHubClient() as client:
|
738
|
+
client.set_user_context(org_id="123", user_id="456")
|
739
|
+
|
740
|
+
gcs_response = await client.blobs.get_gcs_url(file_id="file-001")
|
741
|
+
print(f"GCS URL: {gcs_response.gcs_url}")
|
742
|
+
print(f"MIME类型: {gcs_response.mime_type}")
|
743
|
+
# 输出示例:
|
744
|
+
# GCS URL: gs://bucket-name/path/to/file.pdf
|
745
|
+
# MIME类型: application/pdf
|
746
|
+
```
|
747
|
+
|
748
|
+
**注意**:`get_gcs_url` 方法现在返回一个 `GetGcsUrlResponse` 对象,包含:
|
749
|
+
- `gcs_url`: Google Cloud Storage 的完整路径
|
750
|
+
- `mime_type`: 文件的MIME类型,便于正确处理文件内容
|
751
|
+
|
752
|
+
##### 批量获取GCS URL
|
753
|
+
|
754
|
+
批量获取多个文件的GCS URL和MIME类型信息:
|
755
|
+
|
756
|
+
```python
|
757
|
+
# 异步客户端 - 批量获取GCS URL
|
758
|
+
async with AsyncTamarFileHubClient() as client:
|
759
|
+
client.set_user_context(org_id="123", user_id="456")
|
760
|
+
|
761
|
+
file_ids = ["file-001", "file-002", "file-003"]
|
762
|
+
result = await client.blobs.batch_get_gcs_url(file_ids)
|
763
|
+
|
764
|
+
# 处理结果
|
765
|
+
for url_info in result.gcs_urls:
|
766
|
+
if url_info.error:
|
767
|
+
print(f"文件 {url_info.file_id} 获取GCS URL失败: {url_info.error}")
|
768
|
+
else:
|
769
|
+
print(f"文件 {url_info.file_id}:")
|
770
|
+
print(f" GCS URL: {url_info.gcs_url}")
|
771
|
+
print(f" MIME类型: {url_info.mime_type}")
|
772
|
+
# 根据MIME类型处理文件
|
773
|
+
if url_info.mime_type.startswith('image/'):
|
774
|
+
print(f" 这是一个图片文件")
|
775
|
+
elif url_info.mime_type == 'application/pdf':
|
776
|
+
print(f" 这是一个PDF文件")
|
777
|
+
```
|
778
|
+
|
779
|
+
同步客户端示例:
|
780
|
+
|
781
|
+
```python
|
782
|
+
# 同步客户端 - 批量获取GCS URL
|
783
|
+
with TamarFileHubClient() as client:
|
784
|
+
client.set_user_context(org_id="123", user_id="456")
|
785
|
+
|
786
|
+
# 获取单个GCS URL
|
787
|
+
gcs_response = client.blobs.get_gcs_url(file_id="file-001")
|
788
|
+
print(f"GCS URL: {gcs_response.gcs_url}")
|
789
|
+
print(f"MIME类型: {gcs_response.mime_type}")
|
790
|
+
|
791
|
+
# 批量获取GCS URL
|
792
|
+
result = client.blobs.batch_get_gcs_url(["file-001", "file-002"])
|
793
|
+
```
|
794
|
+
|
795
|
+
##### 使用场景说明
|
796
|
+
|
797
|
+
1. **批量下载URL生成**:
|
798
|
+
- 适用于需要同时下载多个文件的场景
|
799
|
+
- 支持CDN加速,提供更好的下载体验
|
800
|
+
- 可设置URL有效期,增强安全性
|
801
|
+
- 批量操作减少网络往返,提高效率
|
802
|
+
|
803
|
+
2. **GCS URL获取**:
|
804
|
+
- 适用于需要与Google Cloud服务集成的场景
|
805
|
+
- 可用于数据分析、批处理等后端处理
|
806
|
+
- 支持使用GCS工具进行文件操作
|
807
|
+
- 返回的是永久有效的存储路径
|
808
|
+
- 同时返回MIME类型信息,便于正确处理不同类型的文件
|
809
|
+
- 可根据MIME类型选择合适的处理方式(如图片处理、文档解析等)
|
810
|
+
|
811
|
+
3. **错误处理**:
|
812
|
+
- 每个文件独立处理,部分失败不影响其他文件
|
813
|
+
- 错误信息通过 `error` 字段返回
|
814
|
+
- 建议在批量操作时做好错误处理和重试逻辑
|
815
|
+
|
685
816
|
### 文件管理操作
|
686
817
|
|
687
818
|
File Hub Client 提供了完整的文件管理功能,通过 `files` 服务访问:
|
@@ -2019,6 +2150,12 @@ MIT License
|
|
2019
2150
|
|
2020
2151
|
## 更新日志
|
2021
2152
|
|
2153
|
+
### v0.0.5 (2025-01)
|
2154
|
+
- 新增批量下载URL生成接口 (batch_generate_download_url)
|
2155
|
+
- 新增GCS URL获取接口 (get_gcs_url, batch_get_gcs_url)
|
2156
|
+
- GCS URL接口返回MIME类型信息,便于文件类型识别
|
2157
|
+
- 更新相关文档和测试用例
|
2158
|
+
|
2022
2159
|
### v0.0.4 (2025-01)
|
2023
2160
|
- 新增从URL上传文件功能
|
2024
2161
|
- 支持自动下载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=f6PkMS-JGFtDSpbqv77Bf-QqOGY__osHg6WmUtuxlLY,11009
|
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=d6xMVohY3_tLJOQv1nV04pNUlgTM-9v9bkZYnebzraE,4821
|
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=St0FdvzSpJJErhJ3V1vCSSbRN14jggEMS9U8QPqZFiQ,24716
|
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=3VbJGuW7PHCQFK-ip0Y2NRnU39ps3rHnQoxFQp46e3s,24443
|
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.2.dist-info/METADATA,sha256=IDzFkdNun5NF-ugAkJ7URmNpga0Hh9e9RzsYCFp3aAU,70429
|
55
|
+
tamar_file_hub_client-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
56
|
+
tamar_file_hub_client-0.1.2.dist-info/top_level.txt,sha256=9wcR7hyAJQdJg_kuH6WR3nmpJ8O-j8aJNK8f_kcFy6U,16
|
57
|
+
tamar_file_hub_client-0.1.2.dist-info/RECORD,,
|
File without changes
|
{tamar_file_hub_client-0.1.1.dist-info → tamar_file_hub_client-0.1.2.dist-info}/top_level.txt
RENAMED
File without changes
|