tamar-file-hub-client 0.1.1__tar.gz → 0.1.2__tar.gz

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.
Files changed (62) hide show
  1. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/PKG-INFO +138 -1
  2. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/README.md +137 -0
  3. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/file_service_pb2.py +10 -10
  4. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/protos/file_service.proto +3 -1
  5. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/schemas/__init__.py +2 -0
  6. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/schemas/file.py +7 -0
  7. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/file/async_blob_service.py +8 -4
  8. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/file/sync_blob_service.py +8 -4
  9. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/setup.py +1 -1
  10. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/tamar_file_hub_client.egg-info/PKG-INFO +138 -1
  11. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/MANIFEST.in +0 -0
  12. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/__init__.py +0 -0
  13. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/client.py +0 -0
  14. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/enums/__init__.py +0 -0
  15. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/enums/export_format.py +0 -0
  16. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/enums/role.py +0 -0
  17. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/enums/upload_mode.py +0 -0
  18. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/errors/__init__.py +0 -0
  19. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/errors/exceptions.py +0 -0
  20. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/py.typed +0 -0
  21. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/__init__.py +0 -0
  22. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/async_client.py +0 -0
  23. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/__init__.py +0 -0
  24. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/file_service_pb2_grpc.py +0 -0
  25. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/folder_service_pb2.py +0 -0
  26. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/folder_service_pb2_grpc.py +0 -0
  27. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/taple_service_pb2.py +0 -0
  28. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/gen/taple_service_pb2_grpc.py +0 -0
  29. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/interceptors.py +0 -0
  30. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/protos/folder_service.proto +0 -0
  31. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/protos/taple_service.proto +0 -0
  32. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/rpc/sync_client.py +0 -0
  33. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/schemas/context.py +0 -0
  34. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/schemas/folder.py +0 -0
  35. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/schemas/taple.py +0 -0
  36. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/__init__.py +0 -0
  37. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/file/__init__.py +0 -0
  38. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/file/async_file_service.py +0 -0
  39. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/file/base_file_service.py +0 -0
  40. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/file/sync_file_service.py +0 -0
  41. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/folder/__init__.py +0 -0
  42. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/folder/async_folder_service.py +0 -0
  43. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/folder/sync_folder_service.py +0 -0
  44. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/taple/__init__.py +0 -0
  45. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/taple/async_taple_service.py +0 -0
  46. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/taple/base_taple_service.py +0 -0
  47. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/taple/idempotent_taple_mixin.py +0 -0
  48. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/services/taple/sync_taple_service.py +0 -0
  49. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/__init__.py +0 -0
  50. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/converter.py +0 -0
  51. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/download_helper.py +0 -0
  52. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/file_utils.py +0 -0
  53. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/idempotency.py +0 -0
  54. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/logging.py +0 -0
  55. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/retry.py +0 -0
  56. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/smart_retry.py +0 -0
  57. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/file_hub_client/utils/upload_helper.py +0 -0
  58. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/setup.cfg +0 -0
  59. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/tamar_file_hub_client.egg-info/SOURCES.txt +0 -0
  60. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/tamar_file_hub_client.egg-info/dependency_links.txt +0 -0
  61. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/tamar_file_hub_client.egg-info/requires.txt +0 -0
  62. {tamar_file_hub_client-0.1.1 → tamar_file_hub_client-0.1.2}/tamar_file_hub_client.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tamar-file-hub-client
3
- Version: 0.1.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
@@ -636,6 +636,137 @@ async with AsyncTamarFileHubClient() as client:
636
636
  print(f"文件已保存到: {save_path}")
637
637
  ```
638
638
 
639
+ #### 高级下载功能
640
+
641
+ File Hub Client 提供了高级的下载URL管理功能,支持批量操作和直接获取GCS URL:
642
+
643
+ ##### 批量生成下载URL
644
+
645
+ 当需要为多个文件生成下载URL时,使用批量接口可以显著提高效率:
646
+
647
+ ```python
648
+ from file_hub_client import AsyncTamarFileHubClient
649
+
650
+ async with AsyncTamarFileHubClient() as client:
651
+ # 设置用户上下文
652
+ client.set_user_context(org_id="123", user_id="456")
653
+
654
+ # 批量生成下载URL
655
+ file_ids = ["file-001", "file-002", "file-003"]
656
+
657
+ result = await client.blobs.batch_generate_download_url(
658
+ file_ids=file_ids,
659
+ is_cdn=True, # 使用CDN加速(可选,默认为True)
660
+ expire_seconds=3600 # URL有效期1小时(可选)
661
+ )
662
+
663
+ # 处理结果
664
+ for url_info in result.download_urls:
665
+ if url_info.error:
666
+ print(f"文件 {url_info.file_id} 生成URL失败: {url_info.error}")
667
+ else:
668
+ print(f"文件 {url_info.file_id} 的下载URL: {url_info.url}")
669
+ ```
670
+
671
+ 同步客户端示例:
672
+
673
+ ```python
674
+ from file_hub_client import TamarFileHubClient
675
+
676
+ with TamarFileHubClient() as client:
677
+ client.set_user_context(org_id="123", user_id="456")
678
+
679
+ result = client.blobs.batch_generate_download_url(
680
+ file_ids=["file-001", "file-002"],
681
+ is_cdn=False # 不使用CDN,直接返回源站URL
682
+ )
683
+ ```
684
+
685
+ ##### 获取GCS URL
686
+
687
+ 对于需要直接访问Google Cloud Storage的场景,可以获取文件的GCS URL和MIME类型信息:
688
+
689
+ ```python
690
+ # 异步客户端 - 获取单个文件的GCS URL
691
+ async with AsyncTamarFileHubClient() as client:
692
+ client.set_user_context(org_id="123", user_id="456")
693
+
694
+ gcs_response = await client.blobs.get_gcs_url(file_id="file-001")
695
+ print(f"GCS URL: {gcs_response.gcs_url}")
696
+ print(f"MIME类型: {gcs_response.mime_type}")
697
+ # 输出示例:
698
+ # GCS URL: gs://bucket-name/path/to/file.pdf
699
+ # MIME类型: application/pdf
700
+ ```
701
+
702
+ **注意**:`get_gcs_url` 方法现在返回一个 `GetGcsUrlResponse` 对象,包含:
703
+ - `gcs_url`: Google Cloud Storage 的完整路径
704
+ - `mime_type`: 文件的MIME类型,便于正确处理文件内容
705
+
706
+ ##### 批量获取GCS URL
707
+
708
+ 批量获取多个文件的GCS URL和MIME类型信息:
709
+
710
+ ```python
711
+ # 异步客户端 - 批量获取GCS URL
712
+ async with AsyncTamarFileHubClient() as client:
713
+ client.set_user_context(org_id="123", user_id="456")
714
+
715
+ file_ids = ["file-001", "file-002", "file-003"]
716
+ result = await client.blobs.batch_get_gcs_url(file_ids)
717
+
718
+ # 处理结果
719
+ for url_info in result.gcs_urls:
720
+ if url_info.error:
721
+ print(f"文件 {url_info.file_id} 获取GCS URL失败: {url_info.error}")
722
+ else:
723
+ print(f"文件 {url_info.file_id}:")
724
+ print(f" GCS URL: {url_info.gcs_url}")
725
+ print(f" MIME类型: {url_info.mime_type}")
726
+ # 根据MIME类型处理文件
727
+ if url_info.mime_type.startswith('image/'):
728
+ print(f" 这是一个图片文件")
729
+ elif url_info.mime_type == 'application/pdf':
730
+ print(f" 这是一个PDF文件")
731
+ ```
732
+
733
+ 同步客户端示例:
734
+
735
+ ```python
736
+ # 同步客户端 - 批量获取GCS URL
737
+ with TamarFileHubClient() as client:
738
+ client.set_user_context(org_id="123", user_id="456")
739
+
740
+ # 获取单个GCS URL
741
+ gcs_response = client.blobs.get_gcs_url(file_id="file-001")
742
+ print(f"GCS URL: {gcs_response.gcs_url}")
743
+ print(f"MIME类型: {gcs_response.mime_type}")
744
+
745
+ # 批量获取GCS URL
746
+ result = client.blobs.batch_get_gcs_url(["file-001", "file-002"])
747
+ ```
748
+
749
+ ##### 使用场景说明
750
+
751
+ 1. **批量下载URL生成**:
752
+ - 适用于需要同时下载多个文件的场景
753
+ - 支持CDN加速,提供更好的下载体验
754
+ - 可设置URL有效期,增强安全性
755
+ - 批量操作减少网络往返,提高效率
756
+
757
+ 2. **GCS URL获取**:
758
+ - 适用于需要与Google Cloud服务集成的场景
759
+ - 可用于数据分析、批处理等后端处理
760
+ - 支持使用GCS工具进行文件操作
761
+ - 返回的是永久有效的存储路径
762
+ - 同时返回MIME类型信息,便于正确处理不同类型的文件
763
+ - 可根据MIME类型选择合适的处理方式(如图片处理、文档解析等)
764
+
765
+ 3. **错误处理**:
766
+ - 每个文件独立处理,部分失败不影响其他文件
767
+ - 错误信息通过 `error` 字段返回
768
+ - 建议在批量操作时做好错误处理和重试逻辑
769
+
639
770
  ### 文件管理操作
640
771
 
641
772
  File Hub Client 提供了完整的文件管理功能,通过 `files` 服务访问:
@@ -1973,6 +2104,12 @@ MIT License
1973
2104
 
1974
2105
  ## 更新日志
1975
2106
 
2107
+ ### v0.0.5 (2025-01)
2108
+ - 新增批量下载URL生成接口 (batch_generate_download_url)
2109
+ - 新增GCS URL获取接口 (get_gcs_url, batch_get_gcs_url)
2110
+ - GCS URL接口返回MIME类型信息,便于文件类型识别
2111
+ - 更新相关文档和测试用例
2112
+
1976
2113
  ### v0.0.4 (2025-01)
1977
2114
  - 新增从URL上传文件功能
1978
2115
  - 支持自动下载URL内容并上传到GCS
@@ -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\"$\n\x11GetGcsUrlResponse\x12\x0f\n\x07gcs_url\x18\x01 \x01(\t\"<\n\x16\x42\x61tchGetGcsUrlResponse\x12\"\n\x08gcs_urls\x18\x01 \x03(\x0b\x32\x10.file.GcsUrlInfo\"L\n\nGcsUrlInfo\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x0f\n\x07gcs_url\x18\x02 \x01(\t\x12\x12\n\x05\x65rror\x18\x03 \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')
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=2774
84
- _globals['_BATCHGETGCSURLRESPONSE']._serialized_start=2776
85
- _globals['_BATCHGETGCSURLRESPONSE']._serialized_end=2836
86
- _globals['_GCSURLINFO']._serialized_start=2838
87
- _globals['_GCSURLINFO']._serialized_end=2914
88
- _globals['_EMPTY']._serialized_start=2916
89
- _globals['_EMPTY']._serialized_end=2923
90
- _globals['_FILESERVICE']._serialized_start=2926
91
- _globals['_FILESERVICE']._serialized_end=3868
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
- optional string error = 3;
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
  # 文件夹相关
@@ -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
- ) -> str:
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 response.gcs_url
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
- ) -> str:
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 response.gcs_url
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
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="tamar-file-hub-client",
5
- version="0.1.1",
5
+ version="0.1.2",
6
6
  description="A Python SDK for gRPC-based file management system",
7
7
  long_description=open("README.md", encoding="utf-8").read(),
8
8
  long_description_content_type="text/markdown",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tamar-file-hub-client
3
- Version: 0.1.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