dagster-dingtalk 0.1.41__tar.gz → 0.1.43__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 (24) hide show
  1. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/.gitignore +2 -0
  2. dagster_dingtalk-0.1.43/.idea/MarsCodeWorkspaceAppSettings.xml +6 -0
  3. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/workspace.xml +46 -7
  4. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/PKG-INFO +1 -1
  5. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/pyproject.toml +1 -1
  6. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/src/dagster_dingtalk/app_client.py +216 -33
  7. dagster_dingtalk-0.1.43/src/dagster_dingtalk/version.py +1 -0
  8. dagster_dingtalk-0.1.41/src/dagster_dingtalk/version.py +0 -1
  9. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.gitignore +0 -0
  10. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/dagster-dingtalk.iml +0 -0
  11. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/deployment.xml +0 -0
  12. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/dictionaries/admin.xml +0 -0
  13. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/inspectionProfiles/Project_Default.xml +0 -0
  14. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  15. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/misc.xml +0 -0
  16. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/modules.xml +0 -0
  17. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.idea/vcs.xml +0 -0
  18. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/.python-version +0 -0
  19. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/README.md +0 -0
  20. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/desktop.ini +0 -0
  21. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/src/dagster_dingtalk/__init__.py +0 -0
  22. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/src/dagster_dingtalk/operations.py +0 -0
  23. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/src/dagster_dingtalk/py.typed +0 -0
  24. {dagster_dingtalk-0.1.41 → dagster_dingtalk-0.1.43}/src/dagster_dingtalk/resources.py +0 -0
@@ -6,3 +6,5 @@
6
6
  # Datasource local storage ignored files
7
7
  /dataSources/
8
8
  /dataSources.local.xml
9
+ /MarsCodeWorkspaceAppSettings.xml
10
+ /desktop.ini
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="com.codeverse.userSettings.MarscodeWorkspaceAppSettingsState">
4
+ <option name="ckgOperationStatus" value="SUCCESS" />
5
+ </component>
6
+ </project>
@@ -4,9 +4,9 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="d56e898e-6e80-4770-9a14-5869f3cdca54" name="更改" comment="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.39 修改为 0.1.40&#10;- 将 version.py 中的版本号从 0.26.13 修改为 0.26.14">
7
+ <list default="true" id="d56e898e-6e80-4770-9a14-5869f3cdca54" name="更改" comment="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.41 修改为 0.1.42&#10;- 将 version.py 中的版本号从 0.26.17 修改为 0.26.20">
8
8
  <change beforePath="$PROJECT_DIR$/pyproject.toml" beforeDir="false" afterPath="$PROJECT_DIR$/pyproject.toml" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/src/dagster_dingtalk/version.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/dagster_dingtalk/version.py" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/dagster_dingtalk/app_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/dagster_dingtalk/app_client.py" afterDir="false" />
10
10
  </list>
11
11
  <option name="SHOW_DIALOG" value="false" />
12
12
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -51,6 +51,7 @@
51
51
  &quot;keyToString&quot;: {
52
52
  &quot;Python.test.executor&quot;: &quot;Run&quot;,
53
53
  &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
54
+ &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager&quot;: &quot;true&quot;,
54
55
  &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
55
56
  &quot;git-widget-placeholder&quot;: &quot;master&quot;,
56
57
  &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
@@ -108,8 +109,8 @@
108
109
  <component name="SharedIndexes">
109
110
  <attachedChunks>
110
111
  <set>
111
- <option value="bundled-js-predefined-d6986cc7102b-6a121458b545-JavaScript-PY-251.25410.159" />
112
- <option value="bundled-python-sdk-e0ed3721d81e-36ea0e71a18c-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-251.25410.159" />
112
+ <option value="bundled-js-predefined-d6986cc7102b-b26f3e71634d-JavaScript-PY-251.26094.141" />
113
+ <option value="bundled-python-sdk-9f8e2b94138c-36ea0e71a18c-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-251.26094.141" />
113
114
  </set>
114
115
  </attachedChunks>
115
116
  </component>
@@ -144,7 +145,9 @@
144
145
  <workItem from="1746446495722" duration="69000" />
145
146
  <workItem from="1746723436137" duration="161000" />
146
147
  <workItem from="1746881612246" duration="131000" />
147
- <workItem from="1748502555257" duration="29000" />
148
+ <workItem from="1748502555257" duration="70000" />
149
+ <workItem from="1749879333099" duration="4165000" />
150
+ <workItem from="1749889527048" duration="48000" />
148
151
  </task>
149
152
  <task id="LOCAL-00001" summary="更改目录结构以便于使用 uv 构建和发布包">
150
153
  <option name="closed" value="true" />
@@ -258,7 +261,39 @@
258
261
  <option name="project" value="LOCAL" />
259
262
  <updated>1746881714128</updated>
260
263
  </task>
261
- <option name="localTasksCounter" value="15" />
264
+ <task id="LOCAL-00015" summary="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.40 修改为 0.1.41&#10;- 将 version.py 中的版本号从 0.26.14 修改为 0.26.17">
265
+ <option name="closed" value="true" />
266
+ <created>1748502594787</created>
267
+ <option name="number" value="00015" />
268
+ <option name="presentableId" value="LOCAL-00015" />
269
+ <option name="project" value="LOCAL" />
270
+ <updated>1748502594787</updated>
271
+ </task>
272
+ <task id="LOCAL-00016" summary="chore: 更新 .idea/.gitignore 文件&#10;&#10;- 添加 MarsCodeWorkspaceAppSettings.xml 到忽略列表&#10;- 添加 desktop.ini 到忽略列表">
273
+ <option name="closed" value="true" />
274
+ <created>1749883326409</created>
275
+ <option name="number" value="00016" />
276
+ <option name="presentableId" value="LOCAL-00016" />
277
+ <option name="project" value="LOCAL" />
278
+ <updated>1749883326409</updated>
279
+ </task>
280
+ <task id="LOCAL-00017" summary="feat(storage): 优化文件上传接口并添加新功能&#10;&#10;- 新增群文件相关接口,包括获取群存储空间信息、发送文件给指定用户等&#10;- 优化文件上传接口,支持自定义文件冲突策略&#10;- 修复文件传输类中的文件提交方法,支持文件内容直接上传">
281
+ <option name="closed" value="true" />
282
+ <created>1749883365692</created>
283
+ <option name="number" value="00017" />
284
+ <option name="presentableId" value="LOCAL-00017" />
285
+ <option name="project" value="LOCAL" />
286
+ <updated>1749883365692</updated>
287
+ </task>
288
+ <task id="LOCAL-00018" summary="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.41 修改为 0.1.42&#10;- 将 version.py 中的版本号从 0.26.17 修改为 0.26.20">
289
+ <option name="closed" value="true" />
290
+ <created>1749883507831</created>
291
+ <option name="number" value="00018" />
292
+ <option name="presentableId" value="LOCAL-00018" />
293
+ <option name="project" value="LOCAL" />
294
+ <updated>1749883507831</updated>
295
+ </task>
296
+ <option name="localTasksCounter" value="19" />
262
297
  <servers />
263
298
  </component>
264
299
  <component name="TypeScriptGeneratedFilesManager">
@@ -290,7 +325,11 @@
290
325
  <MESSAGE value="build: 更新版本号&#10;&#10;-将 pyproject.toml 中的版本号从 0.1.38 修改为 0.1.39&#10;- 将 src/dagster_dingtalk/version.py 中的版本号从 0.26.12 修改为 0.26.13" />
291
326
  <MESSAGE value="build: 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.38 修改为 0.1.39&#10;- 将 src/dagster_dingtalk/version.py 中的版本号从 0.26.12 修改为 0.26.13" />
292
327
  <MESSAGE value="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.39 修改为 0.1.40&#10;- 将 version.py 中的版本号从 0.26.13 修改为 0.26.14" />
293
- <option name="LAST_COMMIT_MESSAGE" value="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.39 修改为 0.1.40&#10;- 将 version.py 中的版本号从 0.26.13 修改为 0.26.14" />
328
+ <MESSAGE value="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.40 修改为 0.1.41&#10;- 将 version.py 中的版本号从 0.26.14 修改为 0.26.17" />
329
+ <MESSAGE value="chore: 更新 .idea/.gitignore 文件&#10;&#10;- 添加 MarsCodeWorkspaceAppSettings.xml 到忽略列表&#10;- 添加 desktop.ini 到忽略列表" />
330
+ <MESSAGE value="feat(storage): 优化文件上传接口并添加新功能&#10;&#10;- 新增群文件相关接口,包括获取群存储空间信息、发送文件给指定用户等&#10;- 优化文件上传接口,支持自定义文件冲突策略&#10;- 修复文件传输类中的文件提交方法,支持文件内容直接上传" />
331
+ <MESSAGE value="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.41 修改为 0.1.42&#10;- 将 version.py 中的版本号从 0.26.17 修改为 0.26.20" />
332
+ <option name="LAST_COMMIT_MESSAGE" value="build(dagster-dingtalk): 更新版本号&#10;&#10;- 将 pyproject.toml 中的版本号从 0.1.41 修改为 0.1.42&#10;- 将 version.py 中的版本号从 0.26.17 修改为 0.26.20" />
294
333
  </component>
295
334
  <component name="com.intellij.coverage.CoverageDataManagerImpl">
296
335
  <SUITE FILE_PATH="coverage/dagster_dingtalk$test.coverage" NAME="test 覆盖结果" MODIFIED="1739565257857" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-dingtalk
3
- Version: 0.1.41
3
+ Version: 0.1.43
4
4
  Summary: A dagster plugin for the DingTalk
5
5
  Author-email: YiZixuan <sqkkyzx@qq.com>
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dagster-dingtalk"
3
- version = "0.1.41"
3
+ version = "0.1.43"
4
4
  description = "A dagster plugin for the DingTalk"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -531,10 +531,170 @@ class 待办任务__:
531
531
  class 文档文件__:
532
532
  def __init__(self, _client:DingTalkClient):
533
533
  self.__client:DingTalkClient = _client
534
+ self.群文件 = 文档文件__群文件(_client)
534
535
  self.媒体文件 = 文档文件__媒体文件(_client)
536
+ self.存储管理 = 文档文件__存储管理(_client)
535
537
  self.文件传输 = 文档文件__存储管理__文件传输(_client)
536
538
 
537
539
 
540
+ # noinspection NonAsciiCharacters, PyPep8Naming
541
+ class 文档文件__群文件:
542
+ def __init__(self, _client:DingTalkClient):
543
+ self.__client:DingTalkClient = _client
544
+
545
+ def 获取群存储空间信息(self, unionId:str, openConversationId:str) -> dict:
546
+ """
547
+ 接口版本:2025-01-14
548
+
549
+ 调用本接口,可获取某个指定群的存储空间信息,包括群存储空间的ID、群存储空间创建的时间和修改时间等。
550
+
551
+ https://open.dingtalk.com/document/orgapp/obtain-group-storage-space-information
552
+
553
+ :param unionId: 操作人的unionId。
554
+ :param openConversationId: 会话openConversationId。
555
+
556
+ :return:
557
+ {
558
+ "space" : {
559
+ "spaceId" : "798****",
560
+ "corpId" : "ding1234****",
561
+ "createTime" : "2022-01-01T10:00:00Z",
562
+ "modifiedTime" : "2022-01-01T10:00:00Z"
563
+ }
564
+ }
565
+ """
566
+ response = self.__client.api(
567
+ method="POST",
568
+ path=f"/v1.0/convFile/conversations/spaces/query?unionId={unionId}",
569
+ json={'openConversationId': openConversationId}
570
+ )
571
+ return response.json()
572
+
573
+ def 以应用身份发送文件给指定用户(self, unionId:str, spaceId:str, dentryId:str) -> dict:
574
+ """
575
+ 接口版本:2023-01-18
576
+
577
+ 调用本接口可以把存储空间内的文件发送给用户。例如,以当前应用的身份给接收人发送一条工作通知。
578
+
579
+ https://open.dingtalk.com/document/orgapp/sends-a-storage-file-to-a-specified-user
580
+
581
+ :param unionId: 操作人的unionId。
582
+ :param spaceId: 文件所在空间ID。
583
+ :param dentryId: 文件ID。
584
+
585
+ :return:
586
+ {
587
+ "file" : {
588
+ "id" : "674****",
589
+ "conversationId" : "cidB1*****",
590
+ "spaceId" : "864*****",
591
+ "parentId" : "0",
592
+ "type" : "FILE",
593
+ "name" : "测试文件.xls",
594
+ "size" : 256,
595
+ "path" : "/测试文件.xls",
596
+ "version" : 1,
597
+ "status" : "NORMAL",
598
+ "extension" : "xls",
599
+ "creatorId" : "cHtUY****",
600
+ "modifierId" : "cHtUY****",
601
+ "createTime" : "2022-01-01T10:00:00Z",
602
+ "modifiedTime" : "2022-01-01T10:00:00Z"
603
+ }
604
+ }
605
+ """
606
+ response = self.__client.api(
607
+ method="POST",
608
+ path=f"/v1.0/convFile/apps/conversations/files/send?unionId={unionId}",
609
+ json={"spaceId" : spaceId, "dentryId" : dentryId}
610
+ )
611
+ return response.json()
612
+
613
+ def 发送文件到指定会话(self, unionId:str, spaceId:str, dentryId:str, openConversationId:str) -> dict:
614
+ """
615
+ 接口版本:2023-01-18
616
+
617
+ 调用本接口,可实现将存储空间内的文件发送到指定群内。
618
+
619
+ https://open.dingtalk.com/document/orgapp/send-file-to-specified-session
620
+
621
+ :param unionId: 操作人的unionId。
622
+ :param spaceId: 文件所在空间ID。
623
+ :param dentryId: 文件ID。
624
+ :param openConversationId: 会话openConversationId。
625
+
626
+ :return:
627
+ {
628
+ "file" : {
629
+ "id" : "897*****",
630
+ "conversationId" : "cid+vIrz*****",
631
+ "spaceId" : "865*****",
632
+ "parentId" : "parent_id",
633
+ "type" : "FILE",
634
+ "name" : "测试文件.txt",
635
+ "size" : 256,
636
+ "path" : "./测试文件.txt",
637
+ "version" : 1,
638
+ "status" : "NORMAL",
639
+ "extension" : "txt",
640
+ "creatorId" : "chy*****",
641
+ "modifierId" : "chy*****",
642
+ "createTime" : "2022-01-01T10:00:00Z",
643
+ "modifiedTime" : "2022-01-01T10:00:00Z",
644
+ "uuid" : "123*****"
645
+ }
646
+ }
647
+ """
648
+ response = self.__client.api(
649
+ method="POST",
650
+ path=f"/v1.0/convFile/conversations/files/send?unionId={unionId}",
651
+ json={"spaceId": spaceId, "dentryId": dentryId, "openConversationId": openConversationId}
652
+ )
653
+ return response.json()
654
+
655
+ def 发送文件链接到指定会话(self, unionId:str, spaceId:str, dentryId:str, openConversationId:str) -> dict:
656
+ """
657
+ 接口版本:2023-01-18
658
+
659
+ 调用本接口,可实现发送文件链接到指定群内。
660
+
661
+ https://open.dingtalk.com/document/orgapp/send-a-file-link-to-the-specified-session
662
+
663
+ :param unionId: 操作人的unionId。
664
+ :param spaceId: 文件所在空间ID。
665
+ :param dentryId: 文件ID。
666
+ :param openConversationId: 会话openConversationId。
667
+
668
+ :return:
669
+ {
670
+ "file" : {
671
+ "id" : "file_id",
672
+ "conversationId" : "open_conversation_id",
673
+ "spaceId" : "space_id",
674
+ "parentId" : "parent_id",
675
+ "type" : "file",
676
+ "name" : "file_name",
677
+ "size" : 256,
678
+ "path" : "file_path",
679
+ "version" : 1,
680
+ "status" : "NORMAL",
681
+ "extension" : "txt",
682
+ "creatorId" : "creator_id",
683
+ "modifierId" : "modified_id",
684
+ "createTime" : "2022-01-01T10:00:00Z",
685
+ "modifiedTime" : "2022-01-01T10:00:00Z",
686
+ "uuid" : "uuid"
687
+ }
688
+ }
689
+ """
690
+ response = self.__client.api(
691
+ method="POST",
692
+ path=f"/v1.0/convFile/conversations/files/links/send?unionId={unionId}",
693
+ json={"spaceId": spaceId, "dentryId": dentryId, "openConversationId": openConversationId}
694
+ )
695
+ return response.json()
696
+
697
+
538
698
  # noinspection NonAsciiCharacters, PyPep8Naming
539
699
  class 文档文件__媒体文件:
540
700
  def __init__(self, _client:DingTalkClient):
@@ -542,6 +702,8 @@ class 文档文件__媒体文件:
542
702
 
543
703
  def 上传媒体文件(self, file_path:Path|str, media_type:Literal['image', 'voice', 'video', 'file']) -> dict:
544
704
  """
705
+ 接口版本:2023-05-24
706
+
545
707
  调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
546
708
 
547
709
  https://open.dingtalk.com/document/orgapp/upload-media-files
@@ -565,59 +727,73 @@ class 文档文件__媒体文件:
565
727
  return response.json()
566
728
 
567
729
 
730
+ # noinspection NonAsciiCharacters, PyPep8Naming
731
+ class 文档文件__存储管理:
732
+ def __init__(self, _client:DingTalkClient):
733
+ self.__client:DingTalkClient = _client
734
+ self.文件传输 = 文档文件__存储管理__文件传输(self.__client)
735
+
736
+
568
737
  # noinspection NonAsciiCharacters, PyPep8Naming
569
738
  class 文档文件__存储管理__文件传输:
570
739
  def __init__(self, _client:DingTalkClient):
571
740
  self.__client:DingTalkClient = _client
572
741
 
573
- def 获取文件上传信息(self, space_id:int, union_id:str, multi_part:bool = False) -> dict:
742
+ def 获取文件上传信息(self, parentDentryUuid:str, union_id:str) -> dict:
574
743
  """
575
- 调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
744
+ 接口版本:2024-01-05
576
745
 
577
- https://open.dingtalk.com/document/orgapp/upload-media-files
746
+ 调用本接口,获取文件上传信息。
747
+
748
+ https://open.dingtalk.com/document/orgapp/obtain-file-upload-informations
578
749
 
579
- :param space_id: 空间Id。
580
750
  :param union_id: 操作者unionId。
581
- :param multi_part: 是否需要分片上传。默认值为 False
751
+ :param parentDentryUuid: 父节点 dentryUuid,如果是空间根目录, 填空间根目录的dentryUuid。
582
752
 
583
753
  :return:
584
754
  {
585
- "uploadKey": str,
586
- "storageDriver": str,
587
- "protocol": str,
588
- "headerSignatureInfo": {
589
- "resourceUrls" : ["resourceUrl"],
590
- "headers" : {
591
- "key" : "header_value"
592
- },
593
- }
755
+ "uploadKey" : "upload_key",
756
+ "storageDriver" : "DINGTALK",
757
+ "protocol" : "HEADER_SIGNATURE",
758
+ "headerSignatureInfo" : {
759
+ "resourceUrls" : [ "resourceUrl" ],
760
+ "headers" : {
761
+ "key" : "header_value"
762
+ },
763
+ "expirationSeconds" : 900,
764
+ "region" : "ZHANGJIAKOU",
765
+ "internalResourceUrls" : [ "internalResourceUrl" ]
766
+ }
594
767
  }
595
768
  """
596
769
  response = self.__client.api(
597
770
  method="POST",
598
- path=f"/v1.0/storage/spaces/{space_id}/files/uploadInfos/query",
771
+ path=f"/v2.0/storage/spaces/files/{parentDentryUuid}/uploadInfos/query",
599
772
  params={'unionId': union_id},
600
- json={
601
- "protocol": "HEADER_SIGNATURE",
602
- "multipart": multi_part
603
- }
773
+ json={"protocol" : "HEADER_SIGNATURE"}
604
774
  )
605
775
  return response.json()
606
776
 
607
- def 提交文件(self, url:str, headers:dict, file_path:Path|str, space_id:int, union_id:str,
608
- upload_key:str, convert_to_online_doc:bool = False) -> dict:
777
+ def 提交文件(
778
+ self, parentDentryUuid:str, upload_key:str, url:str, headers:dict, file_content: bytes,
779
+ file_path:Path|str, union_id:str, convert_to_online_doc:bool = False,
780
+ conflictStrategy:Literal['AUTO_RENAME', 'OVERWRITE', 'RETURN_DENTRY_IF_EXISTS', 'RETURN_ERROR_IF_EXISTS'] = 'AUTO_RENAME'
781
+ ) -> dict:
609
782
  """
783
+ 接口版本:2023-07-06
784
+
610
785
  调用本接口,上传图片、语音媒体资源文件以及普通文件,接口返回媒体资源标识 media_id。
611
786
 
612
787
  https://open.dingtalk.com/document/orgapp/upload-media-files
613
-
788
+ :param parentDentryUuid: 父节点 dentryUuid。如果是空间根目录,填空间根目录的dentryUuid。
789
+ :param upload_key: 添加文件唯一标识。
614
790
  :param url: 获取文件上传信息得到的 resourceUrl。
615
791
  :param headers: 获取文件上传信息得到的 headers。
616
- :param file_path: 文件路径
617
- :param space_id: 空间Id
792
+ :param file_content: 文件字节内容,如果提供了 file_content,则忽略 file_path。
793
+ :param file_path: 文件路径,如果提供了 file_content,则忽略 file_path
618
794
  :param union_id: 操作者unionId。
619
- :param upload_key: 添加文件唯一标识。
620
795
  :param convert_to_online_doc: 是否转换成在线文档。默认值 False
796
+ :param conflictStrategy: 文件名称冲突策略。AUTO_RENAME:自动重命名,默认值 OVERWRITE:覆盖 RETURN_DENTRY_IF_EXISTS:返回已存在文件 RETURN_ERROR_IF_EXISTS:文件已存在时报错
621
797
 
622
798
  :return:
623
799
  {
@@ -627,20 +803,27 @@ class 文档文件__存储管理__文件传输:
627
803
  "headerSignatureInfo": dict,
628
804
  }
629
805
  """
630
- with open(file_path, 'rb') as f:
631
- httpx.put(
632
- url=url,
633
- files={"file":f},
634
- headers=headers
635
- )
806
+
807
+ if file_content:
808
+ httpx.put(url=url, content=file_content, headers=headers)
809
+ elif file_path:
810
+ file_path = Path(file_path)
811
+ if not file_path.exists():
812
+ raise FileNotFoundError(f"文件路径不存在: {file_path}")
813
+ else:
814
+ with open(file_path, 'rb') as f:
815
+ httpx.put(url=url, files={"file": f}, headers=headers)
816
+ else:
817
+ raise FileNotFoundError(f"未提供任何文件路径或文件内容")
636
818
 
637
819
  response = self.__client.api(
638
820
  method="POST",
639
- path=f"/v2.0/storage/spaces/files/{space_id}/commit?unionId={union_id}",
821
+ path=f"/v2.0/storage/spaces/files/{parentDentryUuid}/commit?unionId={union_id}",
640
822
  json={
641
823
  "uploadKey": upload_key,
642
824
  "name": file_path.split("/")[-1],
643
- "convertToOnlineDoc": convert_to_online_doc
825
+ "convertToOnlineDoc": convert_to_online_doc,
826
+ "option": {"conflictStrategy": conflictStrategy}
644
827
  }
645
828
  )
646
829
  return response.json()
@@ -0,0 +1 @@
1
+ __version__ = "0.26.20"
@@ -1 +0,0 @@
1
- __version__ = "0.26.17"