work/wedrive.pm untested

filter: Statementstmt 0.0% 0 / 301 Branchbran 0.0% 0 / 112 Conditioncond 0.0% 0 / 168 MC/DCmcdc 0.0% 0 / 84 Subroutinesub 0.0% 0 / 34 Podpod 0.0% 0 / 28 totaltotal 0.0% 0 / 727 CC 57 SCAR 24.3
CC
57
Cov
0%
space_create
12.0
space_rename
12.0
space_dismiss
12.0
CRAP 11.3
1 package QQ::weixin::work::wedrive;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::weixin::work::wedrive
8
9 =head1 DESCRIPTION
10
11 微盘
12
13 =cut
14
15 use strict;
16 use base qw(QQ::weixin::work);
17 use Encode;
18 use LWP::UserAgent;
19 use JSON;
20 use utf8;
21
22 our $VERSION = '0.10';
23 our @EXPORT = qw/ space_create space_rename space_dismiss space_info
24 space_acl_add space_acl_del space_setting space_share new_space_info
25 file_list file_upload
26 file_upload_init file_upload_part file_upload_finish
27 file_download file_create file_rename file_move file_delete file_info
28 file_acl_add file_acl_del file_setting file_share
29 get_file_permission file_secure_setting
30 mng_pro_info mng_capacity /;
31
32 =head1 FUNCTION
33
34 管理空间
35
36 =head2 space_create(access_token, hash);
37
38 新建空间
39 最后更新:2022/12/01
40
41 =head2 SYNOPSIS
42
43 L<https://developer.work.weixin.qq.com/document/path/93655>
44
45 =head3 请求说明:
46
47 该接口用于在微盘内新建空间,创建者为应用本身。
48
49 =head4 请求包结构体为:
50
51 {
52 "space_name": "SPACE_NAME",
53 "auth_info": [{
54 "type": 1,
55 "userid": "USERID",
56 "auth": 7
57 }, {
58 "type": 2,
59 "departmentid": DEPARTMENTID,
60 "auth": 1
61 }],
62 "space_sub_type": 0
63 }
64
65 =head4 参数说明:
66
67 参数 类型 必须 说明
68 access_token 是 调用接口凭证
69 space_name string 是 空间标题
70 auth_info obj[] 否 空间其他成员信息
71 type uint32 否 成员类型 1:个人 2:部门
72 userid string 否 成员userid,字符串
73 departmentid uint32 否 部门departmentid, 32位整型范围是[0, 2^32)
74 auth uint32 否 成员权限 1:仅下载 4:可预览(仅专业版微盘企业可设置) 7:应用空间管理员(最多可指定3个,不支持设置部门)
75 space_sub_type uint32 否 区分创建空间类型, 0:普通(目前只支持0)
76
77 =head4 权限说明:
78
79 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
80 第三方应用需具有“微盘”权限
81 代开发自建应用需具有“微盘”权限
82
83 =head3 RETURN 返回结果:
84
85 {
86 "errcode": 0,
87 "errmsg": "ok",
88 "spaceid": "SPACEID"
89 }
90
91 =head4 RETURN 参数说明:
92
93 参数 类型 说明
94 errcode int32 错误码
95 errmsg string 错误码说明
96 spaceid string 空间id
97
98 =cut
99
100 sub space_create {
101 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
102 my $access_token = $_[0];
103 my $json = $_[1];
104 my $ua = LWP::UserAgent->new;
105 $ua->timeout(30);
106 $ua->env_proxy;
107
108 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
109 if ($response->is_success) {
110 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
111 }
112
113 }
114 return 0;
115 }
116
117 =head2 space_rename(access_token, hash);
118
119 重命名空间
120 最后更新:2022/12/01
121
122 =head2 SYNOPSIS
123
124 L<https://developer.work.weixin.qq.com/document/path/97856>
125
126 =head3 请求说明:
127
128 该接口用于重命名已有空间。
129
130 =head4 请求包结构体为:
131
132 {
133 "spaceid": "SPACEID",
134 "space_name": "SPACE_NAME"
135 }
136
137 =head4 参数说明:
138
139 参数 类型 是否必须 说明
140 access_token 是 调用接口凭证
141 spaceid string 是 空间spaceid
142 space_name string 是 重命名后的空间名
143
144 =head4 权限说明:
145
146 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
147 第三方应用需具有“微盘”权限
148 代开发自建应用需具有“微盘”权限
149
150 =head3 RETURN 返回结果:
151
152 {
153 "errcode": 0,
154 "errmsg": "ok"
155 }
156
157 =head4 RETURN 参数说明:
158
159 参数 类型 说明
160 errcode int32 错误码
161 errmsg string 错误码说明
162
163 =cut
164
165 sub space_rename {
166 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
167 my $access_token = $_[0];
168 my $json = $_[1];
169 my $ua = LWP::UserAgent->new;
170 $ua->timeout(30);
171 $ua->env_proxy;
172
173 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_rename?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
174 if ($response->is_success) {
175 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
176 }
177
178 }
179 return 0;
180 }
181
182 =head2 space_dismiss(access_token, hash);
183
184 解散空间
185 最后更新:2022/12/01
186
187 =head2 SYNOPSIS
188
189 L<https://developer.work.weixin.qq.com/document/path/97857>
190
191 =head3 请求说明:
192
193 该接口用于解散已有空间。
194
195 =head4 请求包结构体为:
196
197 {
198 "spaceid": "SPACEID"
199 }
200
201 =head4 参数说明:
202
203 参数 类型 是否必须 说明
204 access_token 是 调用接口凭证
205 spaceid string 是 空间spaceid
206
207 =head4 权限说明:
208
209 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
210 第三方应用需具有“微盘”权限
211 代开发自建应用需具有“微盘”权限
212
213 =head3 RETURN 返回结果:
214
215 {
216 "errcode": 0,
217 "errmsg": "ok"
218 }
219
220 =head4 RETURN 参数说明:
221
222 参数 类型 说明
223 errcode int32 错误码
224 errmsg string 错误码说明
225
226 =cut
227
228 sub space_dismiss {
229 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
230 my $access_token = $_[0];
231 my $json = $_[1];
232 my $ua = LWP::UserAgent->new;
233 $ua->timeout(30);
234 $ua->env_proxy;
235
236 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
237 if ($response->is_success) {
238 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
239 }
240
241 }
242 return 0;
243 }
244
245 =head2 space_info(access_token, hash);
246
247 获取空间信息
248 最后更新:2022/12/01
249
250 =head2 SYNOPSIS
251
252 L<https://developer.work.weixin.qq.com/document/path/97858>
253
254 =head3 请求说明:
255
256 该接口用于获取空间成员列表、信息、权限等信息。
257
258 =head4 请求包结构体为:
259
260 {
261 "spaceid": "SPACEID"
262 }
263
264 =head4 参数说明:
265
266 参数 类型 是否必须 说明
267 access_token 是 调用接口凭证
268 spaceid string 是 空间spaceid
269
270 =head4 权限说明:
271
272 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
273 第三方应用需具有“微盘”权限
274 代开发自建应用需具有“微盘”权限
275
276 =head3 RETURN 返回结果:
277
278 {
279 "errcode": 0,
280 "errmsg": "ok",
281 "space_info": {
282 "spaceid": "SPACEID",
283 "space_name": "SPACE_NAME",
284 "auth_list": {
285 "auth_info": [{
286 "type": 1,
287 "userid": "USERID1",
288 "auth": 3,
289 }, {
290 "type": 1,
291 "userid": "USERID2",
292 "auth": 2
293 }, {
294 "type": 2,
295 "departmentid": DEPARTMENTID1,
296 "auth": 1
297 }],
298 "quit_userid": ["USERID3","USERID4"]
299 }
300 "space_sub_type":0
301 }
302 }
303
304 =head4 RETURN 参数说明:
305
306 参数 类型 说明
307 errcode int32 错误码
308 errmsg string 错误码说明
309 spaceid string 空间spaceid
310 space_name string 空间名称
311 auth_list obj[] 空间成员列表
312 auth_info obj[] 空间成员信息
313 type uint32 成员类型 1:个人 2:部门
314 userid string 成员userid,字符串
315 departmentid uint32 部门departmentid, 32位整型范围是[0, 2^32)
316 auth uint32 成员权限 1:仅下载 4:可预览 7:应用空间管理员
317 quit_userid string[] 空间无权限成员userid (成员在一个有权限的部门中, 自己退出空间或者被移除权限)
318 space_sub_type uint32 空间类型 0:普通
319
320 =cut
321
322 sub space_info {
323 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
324 my $access_token = $_[0];
325 my $json = $_[1];
326 my $ua = LWP::UserAgent->new;
327 $ua->timeout(30);
328 $ua->env_proxy;
329
330 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
331 if ($response->is_success) {
332 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
333 }
334
335 }
336 return 0;
337 }
338
339 =head1 FUNCTION
340
341 管理空间权限
342
343 =head2 space_acl_add(access_token, hash);
344
345 添加成员/部门
346 最后更新:2022/12/01
347
348 =head2 SYNOPSIS
349
350 L<https://developer.work.weixin.qq.com/document/path/93656>
351
352 =head3 请求说明:
353
354 该接口用于对指定空间添加成员/部门,可一次性添加多个。
355
356 =head4 请求包结构体为:
357
358 {
359 "spaceid": "SPACEID",
360 "auth_info": [{
361 "type": 1,
362 "userid": "USERID1",
363 "auth": 7
364 }, {
365 "type": 2,
366 "departmentid": DEPARTMENTID1,
367 "auth": 1
368 }]
369 }
370
371 =head4 参数说明:
372
373 参数 类型 是否必须 说明
374 spaceid string 是 空间spaceid
375 auth_info obj[] 是 被添加的空间成员信息
376 type uint32 是 成员类型 1:个人 2:部门
377 userid string 是 成员userid,字符串 (type为1时填写)
378 departmentid uint32 是 部门departmentid, 32位整型范围是[0, 2^32) (type为2时填写)
379 auth uint32 是 1:仅下载 4:可预览 7:应用空间管理员(连同已经设置的管理员,最多可指定三个,不支持设置部门)
380
381 =head4 权限说明:
382
383 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
384 第三方应用需具有“微盘”权限
385 代开发自建应用需具有“微盘”权限
386
387 =head3 RETURN 返回结果:
388
389 {
390 "errcode": 0,
391 "errmsg": "ok"
392 }
393
394 =head4 RETURN 参数说明:
395
396 参数 类型 说明
397 errcode int32 错误码
398 errmsg string 错误码说明
399
400 =cut
401
402 sub space_acl_add {
403 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
404 my $access_token = $_[0];
405 my $json = $_[1];
406 my $ua = LWP::UserAgent->new;
407 $ua->timeout(30);
408 $ua->env_proxy;
409
410 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_add?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
411 if ($response->is_success) {
412 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
413 }
414
415 }
416 return 0;
417 }
418
419 =head2 space_acl_del(access_token, hash);
420
421 移除成员/部门
422 最后更新:2022/12/01
423
424 =head2 SYNOPSIS
425
426 L<https://developer.work.weixin.qq.com/document/path/97875>
427
428 =head3 请求说明:
429
430 该接口用于对指定空间移除成员/部门,操作者为应用本身。
431
432 =head4 请求包结构体为:
433
434 {
435 "spaceid": "SPACEID",
436 "auth_info": [{
437 "type": 1,
438 "userid": "USERID1"
439 }, {
440 "type": 2,
441 "departmentid": DEPARTMENTID1
442 }]
443 }
444
445 =head4 参数说明:
446
447 参数 类型 是否必须 说明
448 spaceid string 是 空间spaceid
449 auth_info obj[] 是 被移除的空间成员信息
450 type uint32 是 成员类型 1:个人 2:部门
451 userid string 是 成员userid,字符串 (type为1时填写)
452 departmentid uint32 是 部门departmentid, 32位整型范围是[0, 2^32) (type为2时填写)
453
454 =head4 权限说明:
455
456 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
457 第三方应用需具有“微盘”权限
458 代开发自建应用需具有“微盘”权限
459
460 =head3 RETURN 返回结果:
461
462 {
463 "errcode": 0,
464 "errmsg": "ok"
465 }
466
467 =head4 RETURN 参数说明:
468
469 参数 类型 说明
470 errcode int32 错误码
471 errmsg string 错误码说明
472
473 =cut
474
475 sub space_acl_del {
476 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
477 my $access_token = $_[0];
478 my $json = $_[1];
479 my $ua = LWP::UserAgent->new;
480 $ua->timeout(30);
481 $ua->env_proxy;
482
483 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_acl_del?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
484 if ($response->is_success) {
485 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
486 }
487
488 }
489 return 0;
490 }
491
492 =head2 space_setting(access_token, hash);
493
494 安全设置
495 最后更新:2022/12/01
496
497 =head2 SYNOPSIS
498
499 L<https://developer.work.weixin.qq.com/document/path/97876>
500
501 =head3 请求说明:
502
503 该接口用于修改空间权限,应用通过api调用仅支持设置由本应用创建的空间。
504
505 =head4 请求包结构体为:
506
507 {
508 "spaceid": "SPACEID",
509 "enable_watermark": true,
510 "share_url_no_approve": true,
511 "share_url_no_approve_default_auth": 1,
512 "enable_confidential_mode":true,
513 "default_file_scope":1,
514 "ban_share_external":false
515 }
516
517 =head4 参数说明:
518
519 参数 类型 是否必须 说明
520 spaceid string 是 空间spaceid
521 enable_watermark bool 否 (本字段仅专业版企业可设置)启用水印。false:关 true:开 ;如果不填充此字段为保持原有状态
522 enable_confidential_mode bool 否 是否开启保密模式。false:关 true:开 如果不填充此字段为保持原有状态
523 default_file_scope uint32 否 文件默认可查看范围。1:仅成员;2:企业内。如果不填充此字段为保持原有状态
524 ban_share_external bool 否 是否禁止文件分享到企业外|false:关 true:开 如果不填充此字段为保持原有状态
525
526 =head4 权限说明:
527
528 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
529 第三方应用需具有“微盘”权限
530 代开发自建应用需具有“微盘”权限
531
532 =head3 RETURN 返回结果:
533
534 {
535 "errcode": 0,
536 "errmsg": "ok"
537 }
538
539 =head4 RETURN 参数说明:
540
541 参数 类型 说明
542 errcode int32 错误码
543 errmsg string 错误码说明
544
545 =cut
546
547 sub space_setting {
548 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
549 my $access_token = $_[0];
550 my $json = $_[1];
551 my $ua = LWP::UserAgent->new;
552 $ua->timeout(30);
553 $ua->env_proxy;
554
555 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_setting?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
556 if ($response->is_success) {
557 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
558 }
559
560 }
561 return 0;
562 }
563
564 =head2 space_share(access_token, hash);
565
566 获取邀请链接
567 最后更新:2022/12/01
568
569 =head2 SYNOPSIS
570
571 L<https://developer.work.weixin.qq.com/document/path/97877>
572
573 =head3 请求说明:
574
575 该接口用于获取空间邀请分享链接。
576
577 =head4 请求包结构体为:
578
579 {
580 "spaceid": "SPACEID"
581 }
582
583 =head4 参数说明:
584
585 参数 类型 是否必须 说明
586 spaceid string 是 空间spaceid
587
588 =head4 权限说明:
589
590 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
591 第三方应用需具有“微盘”权限
592 代开发自建应用需具有“微盘”权限
593
594 =head3 RETURN 返回结果:
595
596 {
597 "errcode": 0,
598 "errmsg": "ok",
599 "space_share_url": "SPACE_SHARE_URL"
600 }
601
602 =head4 RETURN 参数说明:
603
604 参数 类型 说明
605 errcode int32 错误码
606 errmsg string 错误码说明
607 space_share_url string 邀请链接
608
609 =cut
610
611 sub space_share {
612 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
613 my $access_token = $_[0];
614 my $json = $_[1];
615 my $ua = LWP::UserAgent->new;
616 $ua->timeout(30);
617 $ua->env_proxy;
618
619 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
620 if ($response->is_success) {
621 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
622 }
623
624 }
625 return 0;
626 }
627
628 =head2 new_space_info(access_token, hash);
629
630 获取空间信息
631 最后更新:2022/12/01
632
633 =head2 SYNOPSIS
634
635 L<https://developer.work.weixin.qq.com/document/path/97878>
636
637 =head3 请求说明:
638
639 该接口用于获取空间信息。包括:空间成员及权限及安全设置。
640
641 =head4 请求包结构体为:
642
643 {
644 "spaceid": "SPACEID"
645 }
646
647 =head4 参数说明:
648
649 参数 类型 是否必须 说明
650 spaceid string 是 空间spaceid
651
652 =head4 权限说明:
653
654 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
655 第三方应用需具有“微盘”权限
656 代开发自建应用需具有“微盘”权限
657
658 =head3 RETURN 返回结果:
659
660 {
661 "errcode": 0,
662 "errmsg": "ok",
663 "space_info": {
664 "spaceid": "SPACEID",
665 "space_name": "SPACE_NAME",
666 "auth_list": {
667 "auth_info": [
668 {
669 "type": 1,
670 "userid": "USERID",
671 "auth": 1
672 },
673 {
674 "type": 2,
675 "departmentid": "DEPARTMENTID",
676 "auth": 7
677 }
678 ],
679 "quit_userid": [
680 "USERID1",
681 "USERID2"
682 ]
683 },
684 "space_sub_type": 0,
685 "secure_setting": {
686 "enable_watermark": false,
687 "add_member_only_admin": true,
688 "enable_share_url": false,
689 "share_url_no_approve": false,
690 "share_url_no_approve_default_auth": 2,
691 "enable_share_external": false,
692 "enable_share_external_admin": true,
693 "enable_space_add_external_member": false,
694 "enable_space_add_external_member_admin": true,
695 "enable_confidential_mode": false,
696 "default_file_scope": 2,
697 "create_file_only_admin": false
698 }
699 }
700 }
701
702 =head4 RETURN 参数说明:
703
704 参数 类型 说明
705 errcode int32 错误码
706 errmsg string 错误码说明
707 space_info obj 空间信息
708 spaceid string 空间id
709 space_name string 空间名
710
711 =cut
712
713 sub new_space_info {
714 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
715 my $access_token = $_[0];
716 my $json = $_[1];
717 my $ua = LWP::UserAgent->new;
718 $ua->timeout(30);
719 $ua->env_proxy;
720
721 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/new_space_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
722 if ($response->is_success) {
723 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
724 }
725
726 }
727 return 0;
728 }
729
730 =head1 FUNCTION
731
732 管理文件
733
734 =head2 file_list(access_token, hash);
735
736 获取文件列表
737 最后更新:2022/12/01
738
739 =head2 SYNOPSIS
740
741 L<https://developer.work.weixin.qq.com/document/path/93657>
742
743 =head3 请求说明:
744
745 该接口用于获取指定地址下的文件列表。
746
747 =head4 请求包结构体为:
748
749 {
750 "spaceid": "SPACEID",
751 "fatherid": "FATHERID",
752 "sort_type": 1,
753 "start": 0,
754 "limit": 100
755 }
756
757 =head4 参数说明:
758
759 参数 类型 是否必须 说明
760 spaceid string 是 空间spaceid
761 fatherid string 是 当前目录的fileid,根目录时为空间spaceid
762 sort_type uint32 是 列表排序方式 1:名字升序;2:名字降序;3:大小升序;4:大小降序;5:修改时间升序;6:修改时间降序
763 start uint32 是 首次填0, 后续填上一次请求返回的next_start
764 limit uint32 是 分批拉取最大文件数, 不超过1000
765
766 =head4 权限说明:
767
768 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
769 第三方应用需具有“微盘”权限
770 代开发自建应用需具有“微盘”权限
771
772 =head3 RETURN 返回结果:
773
774 {
775 "errcode": 0,
776 "errmsg": "ok",
777 "has_more": true,
778 "next_start": NEXT_START,
779 "file_list": {
780 "item": [
781 {
782 "fileid": "FILEID1",
783 "file_name": "FILE_NAME1",
784 "spaceid": "SPACEID",
785 "fatherid": "FATHERID",
786 "file_size": FILE_SIZE,
787 "ctime": CTIME,
788 "mtime": MTIME,
789 "file_type": FILE_TYPE,
790 "file_status": FILE_STATUS,
791 "sha": "SHA",
792 "md5": "MD5",
793 "url": "URL"
794 }
795 ]
796 }
797 }
798
799 =head4 RETURN 参数说明:
800
801 参数 类型 说明
802 errcode int32 错误码
803 errmsg string 错误码说明
804 has_more bool true为列表还有内容, 需要继续分批拉取
805 next_start uint32 下次分批拉取对应的请求参数start值
806 file_list obj[] 文件列表
807 fileid string 文件fileid
808 file_name string 文件名字
809 spaceid string 文件所在的空间spaceid
810 fatherid string 文件所在的目录fileid, 在根目录时为fileid
811 file_size uint64 文件大小
812 ctime uint64 文件创建时间
813 mtime uint64 文件最后修改时间
814 file_type uint32 文件类型, 1:文件夹 2:文件 3:微文档(文档) 4:微文档(表格) 5:微文档(收集表)
815 file_status uint32 文件状态, 1:正常 2:删除
816 sha string 文件sha
817 md5 string 文件md5
818 url string 仅微文档类型返回访问链接
819
820 =cut
821
822 sub file_list {
823 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
824 my $access_token = $_[0];
825 my $json = $_[1];
826 my $ua = LWP::UserAgent->new;
827 $ua->timeout(30);
828 $ua->env_proxy;
829
830 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_list?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
831 if ($response->is_success) {
832 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
833 }
834
835 }
836 return 0;
837 }
838
839 =head2 file_upload(access_token, hash);
840
841 上传文件
842 最后更新:2022/12/01
843
844 =head2 SYNOPSIS
845
846 L<https://developer.work.weixin.qq.com/document/path/97880>
847
848 =head3 请求说明:
849
850 该接口用于向微盘中的指定位置上传文件。
851
852 =head4 请求包结构体为:
853
854 {
855 "spaceid": "SPACEID",
856 "fatherid": "FATHERID",
857 "selected_ticket": "SELECTED_TICKET",
858 "file_name": "FILE_NAME",
859 "file_base64_content": "FILE_BASE64_CONTENT"
860 }
861
862 =head4 参数说明:
863
864 参数 类型 是否必须 说明
865 spaceid string 否 空间spaceid
866 fatherid string 否 父目录fileid, 在根目录时为空间spaceid
867 selected_ticket string 否 微盘和文件选择器jsapi返回的selectedTicket。若填此参数,则不需要填spaceid/fatherid。
868 file_name string 是 文件名字(注意:文件名最多填255个字符, 英文算1个, 汉字算2个)
869 file_base64_content string 是 文件内容base64(注意:只需要填入文件内容的Base64,不需要添加任何如:"data:application/x-javascript;base64" 的数据类型描述信息),文件大小上限为10M。大于10M文件,可使用文件分块上传接口
870
871 注意:spaceid/fatherid和selected_ticket必须填且仅填其中一组参数。
872
873 =head4 权限说明:
874
875 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
876 第三方应用需具有“微盘”权限
877 代开发自建应用需具有“微盘”权限
878
879 =head3 RETURN 返回结果:
880
881 {
882 "errcode": 0,
883 "errmsg": "ok",
884 "fileid": "FILEID"
885 }
886
887 =head4 RETURN 参数说明:
888
889 参数 类型 说明
890 errcode int32 错误码
891 errmsg string 错误码说明
892 fileid string 新建文件的fielid
893
894 =cut
895
896 sub file_upload {
897 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
898 my $access_token = $_[0];
899 my $json = $_[1];
900 my $ua = LWP::UserAgent->new;
901 $ua->timeout(30);
902 $ua->env_proxy;
903
904 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
905 if ($response->is_success) {
906 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
907 }
908
909 }
910 return 0;
911 }
912
913 =head2 NAME
914
915 文件分块上传
916 最后更新:2023/03/09
917
918 =head2 file_upload_init(access_token, hash);
919
920 分块上传初始化
921
922 =head2 SYNOPSIS
923
924 L<https://developer.work.weixin.qq.com/document/path/98004#分块上传初始化>
925
926 =head3 请求说明:
927
928 请求分块上传初始化接口,如果命中秒传,则流程结束,完成上传。
929
930 =head4 请求包结构体为:
931
932 {
933 "spaceid": "SPACEID",
934 "fatherid": "FATHERID",
935 "selected_ticket": "SELECTED_TICKET",
936 "file_name": "FILE_NAME",
937 "size": 123,
938 "block_sha": [
939 "STATE1",
940 "STATE2"
941 ],
942 "skip_push_card": false
943 }
944
945 =head4 参数说明:
946
947 参数 类型 是否必须 说明
948 spaceid string 否 空间spaceid
949 fatherid string 否 当前目录的fileid,根目录时为空间spaceid
950 selected_ticket string 否 微盘和文件选择器jsapi返回的selectedTicket。若填此参数,则不需要填spaceid/fatherid。
951 file_name string 是 文件名字
952 size uint64 是 文件大小。最大支持20G
953 block_sha string[] 是 文件分块累积sha值,按分块顺序填入数组。参考附录-分块累积sha说明
954 skip_push_card bool 否 文件创建完成时是否推送企业微信卡片。默认false,即默认推送卡片
955
956 注意:spaceid/fatherid和selected_ticket必须填且仅填其中一组参数。
957
958 =head4 权限说明:
959
960 =head3 RETURN 返回结果:
961
962 {
963 "errcode": 0,
964 "errmsg": "ok",
965 "hit_exist": false,
966 "upload_key": "UPLOAD_KEY",
967 "fileid": "FILEID"
968 }
969
970 =head4 RETURN 参数说明:
971
972 参数 类型 说明
973 errcode int32 错误码
974 errmsg string 错误码说明
975 hit_exist bool 是否命中秒传
976 upload_key string 文件上传凭证。不命中秒传时返回,作为file_upload_part参数
977 fileid string 文件fileid。命中秒传时返回,此时上传流程完成
978
979 =cut
980
981 sub file_upload_init {
982 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
983 my $access_token = $_[0];
984 my $json = $_[1];
985 my $ua = LWP::UserAgent->new;
986 $ua->timeout(30);
987 $ua->env_proxy;
988
989 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload_init?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
990 if ($response->is_success) {
991 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
992 }
993
994 }
995 return 0;
996 }
997
998 =head2 file_upload_part(access_token, hash);
999
1000 分块上传文件
1001
1002 =head2 SYNOPSIS
1003
1004 L<https://developer.work.weixin.qq.com/document/path/98004#分块上传文件>
1005
1006 =head3 请求说明:
1007
1008 将文件内容按2M分块,依次请求分块上传文件接口。
1009
1010 =head4 请求包结构体为:
1011
1012 {
1013 "upload_key": "UPLOAD_KEY",
1014 "index": 1,
1015 "file_base64_content": "FILE_BASE64_CONTENT"
1016 }
1017
1018 =head4 参数说明:
1019
1020 参数 类型 是否必须 说明
1021 upload_key string 是 文件上传凭证。file_upload_init返回的upload_key
1022 index int32 是 文件分块号。文件内容按2M分块,从1开始
1023 file_base64_content string 是 分块的文件内容base64。(注意:只需要填入文件内容的Base64,不需要添加任何如:"data:application/x-javascript;base64" 的数据类型描述信息)
1024
1025 =head4 权限说明:
1026
1027 =head3 RETURN 返回结果:
1028
1029 {
1030 "errcode": 0,
1031 "errmsg": "ok"
1032 }
1033
1034 =head4 RETURN 参数说明:
1035
1036 参数 类型 说明
1037 errcode int32 错误码
1038 errmsg string 错误码说明
1039
1040 =cut
1041
1042 sub file_upload_part {
1043 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1044 my $access_token = $_[0];
1045 my $json = $_[1];
1046 my $ua = LWP::UserAgent->new;
1047 $ua->timeout(30);
1048 $ua->env_proxy;
1049
1050 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload_part?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1051 if ($response->is_success) {
1052 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1053 }
1054
1055 }
1056 return 0;
1057 }
1058
1059 =head2 file_upload_finish(access_token, hash);
1060
1061 分块上传完成
1062
1063 =head2 SYNOPSIS
1064
1065 L<https://developer.work.weixin.qq.com/document/path/98004#分块上传完成>
1066
1067 =head3 请求说明:
1068
1069 请求分块上传完成接口,流程结束,完成上传。
1070
1071 =head4 请求包结构体为:
1072
1073 {
1074 "upload_key": "UPLOAD_KEY"
1075 }
1076
1077 =head4 参数说明:
1078
1079 参数 类型 是否必须 说明
1080 upload_key string 是 文件上传凭证。file_upload_init返回的upload_key
1081
1082 =head4 权限说明:
1083
1084 =head3 RETURN 返回结果:
1085
1086 {
1087 "errcode": 0,
1088 "errmsg": "ok",
1089 "fileid": "FILEID"
1090 }
1091
1092 =head4 RETURN 参数说明:
1093
1094 参数 类型 说明
1095 errcode int32 错误码
1096 errmsg string 错误码说明
1097 fileid string 文件fileid
1098
1099 =head4 附录-分块累积sha说明
1100
1101 L<https://developer.work.weixin.qq.com/document/path/98004#附录-分块累积sha说明>
1102
1103 =cut
1104
1105 sub file_upload_finish {
1106 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1107 my $access_token = $_[0];
1108 my $json = $_[1];
1109 my $ua = LWP::UserAgent->new;
1110 $ua->timeout(30);
1111 $ua->env_proxy;
1112
1113 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_upload_finish?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1114 if ($response->is_success) {
1115 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1116 }
1117
1118 }
1119 return 0;
1120 }
1121
1122 =head2 file_download(access_token, hash);
1123
1124 下载文件
1125 最后更新:2022/12/01
1126
1127 =head2 SYNOPSIS
1128
1129 L<https://developer.work.weixin.qq.com/document/path/97881>
1130
1131 =head3 请求说明:
1132
1133 该接口用于下载文件。
1134
1135 =head4 请求包结构体为:
1136
1137 {
1138 "fileid": "FILEID",
1139 "selected_ticket": "SELECTED_TICKET"
1140 }
1141
1142 =head4 参数说明:
1143
1144 参数 类型 是否必须 说明
1145 fileid string 否 文件fileid(只支持下载普通文件,不支持下载文件夹或微文档)
1146 selected_ticket string 否 微盘和文件选择器jsapi返回的selectedTicket。若填此参数,则不需要填fileid。
1147
1148 注意:fileid和selected_ticket必须填且仅填其中一组参数。
1149
1150 =head4 权限说明:
1151
1152 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1153 第三方应用需具有“微盘”权限
1154 代开发自建应用需具有“微盘”权限
1155
1156 =head3 RETURN 返回结果:
1157
1158 {
1159 "errcode": 0,
1160 "errmsg": "ok",
1161 "download_url": "DOWNLOAD_URL",
1162 "cookie_name": "COOKIE_NAME",
1163 "cookie_value": "COOKIE_VALUE"
1164 }
1165
1166 =head4 RETURN 参数说明:
1167
1168 参数 类型 说明
1169 errcode int32 错误码
1170 errmsg string 错误码说明
1171 download_url string 下载请求url (有效期2个小时)
1172 cookie_name string 下载请求带cookie的key
1173 cookie_value string 下载请求带cookie的value
1174
1175 =cut
1176
1177 sub file_download {
1178 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1179 my $access_token = $_[0];
1180 my $json = $_[1];
1181 my $ua = LWP::UserAgent->new;
1182 $ua->timeout(30);
1183 $ua->env_proxy;
1184
1185 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1186 if ($response->is_success) {
1187 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1188 }
1189
1190 }
1191 return 0;
1192 }
1193
1194 =head2 file_create(access_token, hash);
1195
1196 新建文件夹/文档
1197 最后更新:2022/12/01
1198
1199 =head2 SYNOPSIS
1200
1201 L<https://developer.work.weixin.qq.com/document/path/97882>
1202
1203 =head3 请求说明:
1204
1205 该接口用于在微盘指定位置新建文件夹、文档(更多文档接口能力可见文档API接口说明)。
1206
1207 =head4 请求包结构体为:
1208
1209 {
1210 "spaceid": "SPACEID",
1211 "fatherid": "FATHERID",
1212 "file_type": FILE_TYPE,
1213 "file_name": "FILE_NAME"
1214 }
1215
1216 =head4 参数说明:
1217
1218 参数 类型 是否必须 说明
1219 spaceid string 是 空间spaceid
1220 fatherid string 是 父目录fileid, 在根目录时为空间spaceid
1221 file_type uint32 是 文件类型, 1:文件夹 3:文档(文档) 4:文档(表格)
1222 file_name string 是 文件名字(注意:文件名最多填255个字符, 英文算1个, 汉字算2个)
1223
1224 =head4 权限说明:
1225
1226 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1227 第三方应用需具有“微盘”权限
1228 代开发自建应用需具有“微盘”权限
1229
1230 =head3 RETURN 返回结果:
1231
1232 {
1233 "errcode": 0,
1234 "errmsg": "ok",
1235 "fileid": "FILEID",
1236 "url": "URL"
1237 }
1238
1239 =head4 RETURN 参数说明:
1240
1241 参数 类型 说明
1242 errcode int32 错误码
1243 errmsg string 错误码说明
1244 fileid string 新建文件的fileid
1245 url string 文档的访问链接,仅在新建文档时返回
1246
1247 =cut
1248
1249 sub file_create {
1250 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1251 my $access_token = $_[0];
1252 my $json = $_[1];
1253 my $ua = LWP::UserAgent->new;
1254 $ua->timeout(30);
1255 $ua->env_proxy;
1256
1257 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1258 if ($response->is_success) {
1259 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1260 }
1261
1262 }
1263 return 0;
1264 }
1265
1266 =head2 file_rename(access_token, hash);
1267
1268 重命名文件
1269 最后更新:2022/12/01
1270
1271 =head2 SYNOPSIS
1272
1273 L<https://developer.work.weixin.qq.com/document/path/97883>
1274
1275 =head3 请求说明:
1276
1277 该接口用于对指定文件进行重命名。
1278
1279 =head4 请求包结构体为:
1280
1281 {
1282 "fileid": "FILEID",
1283 "new_name": "NEW_NAME"
1284 }
1285
1286 =head4 参数说明:
1287
1288 参数 类型 是否必须 说明
1289 fileid string 是 文件fileid
1290 new_name string 是 重命名后的文件名 (注意:文件名最多填255个字符, 英文算1个, 汉字算2个)
1291
1292 =head4 权限说明:
1293
1294 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1295 第三方应用需具有“微盘”权限
1296 代开发自建应用需具有“微盘”权限
1297
1298 =head3 RETURN 返回结果:
1299
1300 {
1301 "errcode": 0,
1302 "errmsg": "ok",
1303 "file": {
1304 "fileid": "FILEID",
1305 "file_name": "FILE_NAME",
1306 "spaceid": "SPACEID",
1307 "fatherid": "FATHERID",
1308 "file_size": FILE_SIZE,
1309 "ctime": CTIME,
1310 "mtime": MTIME,
1311 "file_type": FILE_TYPE,
1312 "file_status": FILE_STATUS,
1313 "sha": "SHA",
1314 "md5": "MD5"
1315 }
1316 }
1317
1318 =head4 RETURN 参数说明:
1319
1320 参数 类型 说明
1321 errcode int32 错误码
1322 errmsg string 错误码说明
1323 fileid string 文件fileid
1324 file_name string 文件名字
1325 spaceid string 文件所在的空间spaceid
1326 fatherid string 文件所在的目录fileid, 在根目录时为spaceid
1327 file_size uint64 文件大小
1328 ctime uint64 文件创建时间
1329 mtime uint64 文件最后修改时间
1330 file_type uint32 文件类型, 1:文件夹 2:文件 3:文档(文档) 4:文档(表格) 5:文档(收集表) 6:文档(幻灯片)
1331 file_status uint32 文件状态, 1:正常 2:删除
1332 sha string 文件sha
1333 md5 string 文件md5
1334
1335 =cut
1336
1337 sub file_rename {
1338 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1339 my $access_token = $_[0];
1340 my $json = $_[1];
1341 my $ua = LWP::UserAgent->new;
1342 $ua->timeout(30);
1343 $ua->env_proxy;
1344
1345 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_rename?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1346 if ($response->is_success) {
1347 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1348 }
1349
1350 }
1351 return 0;
1352 }
1353
1354 =head2 file_move(access_token, hash);
1355
1356 移动文件
1357 最后更新:2022/12/01
1358
1359 =head2 SYNOPSIS
1360
1361 L<https://developer.work.weixin.qq.com/document/path/97884>
1362
1363 =head3 请求说明:
1364
1365 该接口用于将文件移动到指定位置。
1366
1367 =head4 请求包结构体为:
1368
1369 {
1370 "fatherid": "FATHERID",
1371 "replace": true,
1372 "fileid": ["FILEID1", "FILEID2"]
1373 }
1374
1375 =head4 参数说明:
1376
1377 参数 类型 是否必须 说明
1378 fatherid string 是 当前目录的fileid,根目录时为空间spaceid
1379 replace bool 否 如果移动到的目标目录与需要移动的文件重名时,是否覆盖。true:重名文件覆盖 false:重名文件进行冲突重命名处理(移动后文件名格式如xxx(1).txt xxx(1).doc等)
1380 fileid string 是 文件fileid
1381
1382 =head4 权限说明:
1383
1384 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1385 第三方应用需具有“微盘”权限
1386 代开发自建应用需具有“微盘”权限
1387
1388 =head3 RETURN 返回结果:
1389
1390 {
1391 "errcode": 0,
1392 "errmsg": "ok",
1393 "file_list": {
1394 "item": [
1395 {
1396 "fileid": "FILEID",
1397 "file_name": "FILE_NAME",
1398 "spaceid": "SPACEID",
1399 "fatherid": "FATHERID",
1400 "file_size": FILE_SIZE,
1401 "ctime": CTIME,
1402 "mtime": MTIME,
1403 "file_type": FILE_TYPE,
1404 "file_status": FILE_STATUS,
1405 "sha": "SHA",
1406 "md5": "MD5"
1407 }
1408 ]
1409 }
1410 }
1411
1412 =head4 RETURN 参数说明:
1413
1414 参数 类型 说明
1415 errcode int32 错误码
1416 errmsg string 错误码说明
1417 file_list obj[] 移动文件的信息列表
1418 fileid string 文件fileid
1419 file_name string 文件名字
1420 spaceid string 文件所在的空间spaceid
1421 fatherid string 文件所在的目录fileid, 在根目录时为fileid
1422 file_size uint64 文件大小
1423 ctime uint64 文件创建时间
1424 mtime uint64 文件最后修改时间
1425 file_type uint32 文件类型, 1:文件夹 2:文件 3:文档(文档) 4:文档(表格) 5:文档(收集表) 6:文档(幻灯片)
1426 file_status uint32 文件状态, 1:正常 2:删除
1427 sha string 文件sha
1428 md5 string 文件md5
1429
1430 =cut
1431
1432 sub file_move {
1433 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1434 my $access_token = $_[0];
1435 my $json = $_[1];
1436 my $ua = LWP::UserAgent->new;
1437 $ua->timeout(30);
1438 $ua->env_proxy;
1439
1440 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_move?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1441 if ($response->is_success) {
1442 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1443 }
1444
1445 }
1446 return 0;
1447 }
1448
1449 =head2 file_delete(access_token, hash);
1450
1451 删除文件
1452 最后更新:2022/12/01
1453
1454 =head2 SYNOPSIS
1455
1456 L<https://developer.work.weixin.qq.com/document/path/97885>
1457
1458 =head3 请求说明:
1459
1460 该接口用于删除指定文件。
1461
1462 =head4 请求包结构体为:
1463
1464 {
1465 "fileid": ["FILEID1", "FILEID2"]
1466 }
1467
1468 =head4 参数说明:
1469
1470 参数 类型 是否必须 说明
1471 fileid string[] 是 文件fileid
1472
1473 =head4 权限说明:
1474
1475 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1476 第三方应用需具有“微盘”权限
1477 代开发自建应用需具有“微盘”权限
1478
1479 =head3 RETURN 返回结果:
1480
1481 {
1482 "errcode": 0,
1483 "errmsg": "ok"
1484 }
1485
1486 =head4 RETURN 参数说明:
1487
1488 参数 类型 说明
1489 errcode int32 错误码
1490 errmsg string 错误码说明
1491
1492 =cut
1493
1494 sub file_delete {
1495 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1496 my $access_token = $_[0];
1497 my $json = $_[1];
1498 my $ua = LWP::UserAgent->new;
1499 $ua->timeout(30);
1500 $ua->env_proxy;
1501
1502 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_delete?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1503 if ($response->is_success) {
1504 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1505 }
1506
1507 }
1508 return 0;
1509 }
1510
1511 =head2 file_info(access_token, hash);
1512
1513 获取文件信息
1514 最后更新:2022/12/26
1515
1516 =head2 SYNOPSIS
1517
1518 L<https://developer.work.weixin.qq.com/document/path/97886>
1519
1520 =head3 请求说明:
1521
1522 该接口用于获取指定文件的信息。
1523
1524 =head4 请求包结构体为:
1525
1526 {
1527 "fileid": "FILEID"
1528 }
1529
1530 =head4 参数说明:
1531
1532 参数 类型 是否必须 说明
1533 fileid string 是 文件fileid
1534
1535 =head4 权限说明:
1536
1537 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1538 第三方应用需具有“微盘”权限
1539 代开发自建应用需具有“微盘”权限
1540
1541 =head3 RETURN 返回结果:
1542
1543 {
1544 "errcode": 0,
1545 "errmsg": "ok",
1546 "file_info": {
1547 "fileid": "FILEID",
1548 "file_name": "FILE_NAME",
1549 "spaceid": "SPACEID",
1550 "fatherid": "FATHERID",
1551 "file_size": FILE_SIZE,
1552 "ctime": CTIME,
1553 "mtime": MTIME,
1554 "file_type": FILE_TYPE,
1555 "file_status": FILE_STATUS,
1556 "sha": "SHA",
1557 "md5": "MD5",
1558 "url": "URL"
1559 }
1560 }
1561
1562 =head4 RETURN 参数说明:
1563
1564 参数 类型 说明
1565 errcode int32 错误码
1566 errmsg string 错误码说明
1567 fileid string 文件fileid
1568 file_name string 文件名字
1569 spaceid string 文件所在的空间spaceid
1570 fatherid string 文件所在的目录fileid, 在根目录时为fileid
1571 file_size uint64 文件大小
1572 ctime uint64 文件创建时间
1573 mtime uint64 文件最后修改时间
1574 file_type uint32 1: 文件夹 2:文件 3: 文档(文档) 4: 文档(表格) 5:文档(收集表) 6:文档(幻灯片)
1575 file_status uint32 文件状态, 1:正常 2:删除
1576 sha string 文件sha。可用于确认是否跟与上传的文件一致,或避免重复上传相同的文件
1577 md5 string 文件md5。可用于确认是否跟与上传的文件一致,或避免重复上传相同的文件
1578 url string 仅微文档类型返回访问链接
1579
1580 =cut
1581
1582 sub file_info {
1583 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1584 my $access_token = $_[0];
1585 my $json = $_[1];
1586 my $ua = LWP::UserAgent->new;
1587 $ua->timeout(30);
1588 $ua->env_proxy;
1589
1590 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1591 if ($response->is_success) {
1592 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1593 }
1594
1595 }
1596 return 0;
1597 }
1598
1599 =head1 FUNCTION
1600
1601 管理文件权限
1602
1603 =head2 file_acl_add(access_token, hash);
1604
1605 新增成员
1606 最后更新:2022/12/01
1607
1608 =head2 SYNOPSIS
1609
1610 L<https://developer.work.weixin.qq.com/document/path/93658>
1611
1612 =head3 请求说明:
1613
1614 该接口用于对指定文件添加成员。
1615
1616 =head4 请求包结构体为:
1617
1618 {
1619 "fileid": "FILEID",
1620 "auth_info": [{
1621 "type":2,
1622 "departmentid": DEPARTMENTID1,
1623 "auth": 1
1624 }, {
1625 "type":1,
1626 "userid": "USERID1",
1627 "auth": 4
1628 }]
1629 }
1630
1631 =head4 参数说明:
1632
1633 参数 类型 是否必须 说明
1634 fileid string 是 文件fileid
1635 auth_info obj[] 是 添加成员的信息
1636 type(后续将废弃) uint32 是 成员类型 1:个人 2:部门
1637 userid string 是 成员userid,字符串
1638 departmentid(后续将废弃) uint32 是 部门departmentid, 32位整型范围是[0, 2^32) (type为2时填写)
1639 auth uint32 是 选项包括1:仅下载(仅浏览);4:仅预览
1640
1641 =head4 权限说明:
1642
1643 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1644 第三方应用需具有“微盘”权限
1645 代开发自建应用需具有“微盘”权限
1646
1647 =head3 RETURN 返回结果:
1648
1649 {
1650 "errcode": 0,
1651 "errmsg": "ok"
1652 }
1653
1654 =head4 RETURN 参数说明:
1655
1656 参数 类型 说明
1657 errcode int32 错误码
1658 errmsg string 错误码说明
1659
1660 =cut
1661
1662 sub file_acl_add {
1663 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1664 my $access_token = $_[0];
1665 my $json = $_[1];
1666 my $ua = LWP::UserAgent->new;
1667 $ua->timeout(30);
1668 $ua->env_proxy;
1669
1670 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_add?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1671 if ($response->is_success) {
1672 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1673 }
1674
1675 }
1676 return 0;
1677 }
1678
1679 =head2 file_acl_del(access_token, hash);
1680
1681 删除成员
1682 最后更新:2022/12/01
1683
1684 =head2 SYNOPSIS
1685
1686 L<https://developer.work.weixin.qq.com/document/path/97888>
1687
1688 =head3 请求说明:
1689
1690 该接口用于删除指定文件的成员。
1691
1692 =head4 请求包结构体为:
1693
1694 {
1695 "fileid": "FILEID",
1696 "auth_info": [{
1697 "type":1,
1698 "userid": "USERID1"
1699 },{
1700 "type":2,
1701 "departmentid": DEPARTMENTID1
1702 }]
1703 }
1704
1705 =head4 参数说明:
1706
1707 参数 类型 是否必须 说明
1708 fileid string 是 文件fileid
1709 auth_info obj[] 是 被移除的成员信息
1710 type(后续将废弃) uint32 是 成员类型 1:个人 2:部门
1711 userid string 是 成员userid,字符串
1712 departmentid(后续将废弃) uint32 是 部门departmentid, 32位整型范围是[0, 2^32) (type为2时填写)
1713
1714 =head4 权限说明:
1715
1716 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1717 第三方应用需具有“微盘”权限
1718 代开发自建应用需具有“微盘”权限
1719
1720 =head3 RETURN 返回结果:
1721
1722 {
1723 "errcode": 0,
1724 "errmsg": "ok"
1725 }
1726
1727 =head4 RETURN 参数说明:
1728
1729 参数 类型 说明
1730 errcode int32 错误码
1731 errmsg string 错误码说明
1732
1733 =cut
1734
1735 sub file_acl_del {
1736 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1737 my $access_token = $_[0];
1738 my $json = $_[1];
1739 my $ua = LWP::UserAgent->new;
1740 $ua->timeout(30);
1741 $ua->env_proxy;
1742
1743 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_acl_del?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1744 if ($response->is_success) {
1745 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1746 }
1747
1748 }
1749 return 0;
1750 }
1751
1752 =head2 file_setting(access_token, hash);
1753
1754 分享设置
1755 最后更新:2022/12/01
1756
1757 =head2 SYNOPSIS
1758
1759 L<https://developer.work.weixin.qq.com/document/path/97889>
1760
1761 =head3 请求说明:
1762
1763 该接口用于文件的分享设置。
1764
1765 =head4 请求包结构体为:
1766
1767 {
1768 "fileid": "FILDID",
1769 "auth_scope": AUTH_SCOPE,
1770 "auth": 1
1771 }
1772
1773 =head4 参数说明:
1774
1775 参数 类型 是否必须 说明
1776 fileid string 是 文件fileid
1777 auth_scope uint32 是 权限范围:1:指定人 2:企业内 3:企业外 4: 企业内需管理员审批(仅有管理员时可设置) 5: 企业外需管理员审批(仅有管理员时可设置)
1778 auth uint32 否 权限信息
1779 普通文档: 1:仅浏览(可下载) 4:仅预览(仅专业版企业可设置);如果不填充此字段为保持原有状态
1780 微文档: 1:仅浏览(可下载);如果不填充此字段为保持原有状态
1781
1782 =head4 权限说明:
1783
1784 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1785 第三方应用需具有“微盘”权限
1786 代开发自建应用需具有“微盘”权限
1787
1788 =head3 RETURN 返回结果:
1789
1790 {
1791 "errcode": 0,
1792 "errmsg": "ok"
1793 }
1794
1795 =head4 RETURN 参数说明:
1796
1797 参数 类型 说明
1798 errcode int32 错误码
1799 errmsg string 错误码说明
1800
1801 =cut
1802
1803 sub file_setting {
1804 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1805 my $access_token = $_[0];
1806 my $json = $_[1];
1807 my $ua = LWP::UserAgent->new;
1808 $ua->timeout(30);
1809 $ua->env_proxy;
1810
1811 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1812 if ($response->is_success) {
1813 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1814 }
1815
1816 }
1817 return 0;
1818 }
1819
1820 =head2 file_share(access_token, hash);
1821
1822 获取分享链接
1823 最后更新:2022/12/01
1824
1825 =head2 SYNOPSIS
1826
1827 L<https://developer.work.weixin.qq.com/document/path/97890>
1828
1829 =head3 请求说明:
1830
1831 该接口用于获取文件的分享链接。
1832
1833 =head4 请求包结构体为:
1834
1835 {
1836 "fileid": "FILDID"
1837 }
1838
1839 =head4 参数说明:
1840
1841 参数 类型 是否必须 说明
1842 fileid string 是 文件fileid
1843
1844 =head4 权限说明:
1845
1846 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1847 第三方应用需具有“微盘”权限
1848 代开发自建应用需具有“微盘”权限
1849
1850 =head3 RETURN 返回结果:
1851
1852 {
1853 "errcode": 0,
1854 "errmsg": "ok",
1855 "share_url": "SHARE_URL"
1856 }
1857
1858 =head4 RETURN 参数说明:
1859
1860 参数 类型 说明
1861 errcode int32 错误码
1862 errmsg string 错误码说明
1863 share_url string 分享文件的链接
1864
1865 =cut
1866
1867 sub file_share {
1868 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1869 my $access_token = $_[0];
1870 my $json = $_[1];
1871 my $ua = LWP::UserAgent->new;
1872 $ua->timeout(30);
1873 $ua->env_proxy;
1874
1875 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
1876 if ($response->is_success) {
1877 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
1878 }
1879
1880 }
1881 return 0;
1882 }
1883
1884 =head2 get_file_permission(access_token, hash);
1885
1886 获取文件权限信息
1887 最后更新:2023/03/15
1888
1889 =head2 SYNOPSIS
1890
1891 L<https://developer.work.weixin.qq.com/document/path/97891>
1892
1893 =head3 请求说明:
1894
1895 该接口用于获取文件的权限信息。
1896
1897 =head4 请求包结构体为:
1898
1899 {
1900 "fileid": "FILDID"
1901 }
1902
1903 =head4 参数说明:
1904
1905 参数 类型 是否必须 说明
1906 fileid string 是 文件fileid
1907
1908 =head4 权限说明:
1909
1910 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
1911 第三方应用需具有“微盘”权限
1912 代开发自建应用需具有“微盘”权限
1913
1914 =head3 RETURN 返回结果:
1915
1916 {
1917 "errcode": 0,
1918 "errmsg": "ok",
1919 "share_range": {
1920 "enable_corp_internal": true,
1921 "corp_internal_auth": 1,
1922 "enable_corp_external": false,
1923 "corp_external_auth": 2
1924 },
1925 "secure_setting": {
1926 "enable_readonly_copy": true,
1927 "modify_only_by_admin": true,
1928 "enable_readonly_comment": false,
1929 "ban_share_external": true
1930 },
1931 "inherit_father_auth": {
1932 "auth_list": [
1933 {
1934 "type": 1,
1935 "userid": "USERID",
1936 "auth": 1
1937 }
1938 ],
1939 "inherit": true
1940 },
1941 "file_member_list": [
1942 {
1943 "type": 1,
1944 "userid": "USERID",
1945 "auth": 1
1946 }
1947 ],
1948 "watermark": {
1949 "text": "WATERMARK_TEXT",
1950 "margin_type": 1,
1951 "show_visitor_name": false,
1952 "force_by_admin": false,
1953 "show_text": false,
1954 "force_by_space_admin": false
1955 }
1956 }
1957
1958 =head4 RETURN 参数说明:
1959
1960 参数 类型 说明
1961 errcode int32 错误码
1962 errmsg string 错误码说明
1963 share_range obj 文件分享设置
1964 enable_corp_internal bool 是否为企业内可访问
1965 corp_internal_auth uint32 企业内权限信息
1966 普通文档: 1:仅浏览(可下载) 4:仅预览(仅专业版企业可设置)255:无权限或需要审批;如果不填充此字段为保持原有状态
1967 微文档: 1:仅浏览(可下载);如果不填充此字段为保持原有状态
1968 enable_corp_external bool 是否为企业外可访问
1969 corp_external_auth uint32 企业外权限信息
1970 普通文档: 1:仅浏览(可下载) 4:仅预览(仅专业版企业可设置) 255:无权限或需要审批;如果不填充此字段为保持原有状态
1971 微文档: 1:仅浏览(可下载);如果不填充此字段为保持原有状态
1972 corp_internal_approve_only_by_admin bool 是否开启企业内管理员审批
1973 corp_external_approve_only_by_admin bool 是否开启企业外管理员审批
1974 secure_setting obj 文件安全配置
1975 enable_readonly_copy bool 是否开启只读备份
1976 modify_only_by_admin bool 是否只允许管理员进行修改
1977 enable_readonly_comment bool 是否开启只读评论
1978 ban_share_external bool 是否禁止分享到企业外部
1979 inherit_father_auth obj 从文件父路径继承的权限
1980 inherit bool 文件是否开启父路径权限继承
1981 member_list obj 文件夹、文档成员
1982 file_member_list obj 查询fileid为文档时返回,为文档所在目录成员,以及其他授权列表
1983 co_auth_list obj 分享指定的部门列表
1984 type(后续将废弃) uint32 成员类型 1:个人 2:部门
1985 userid string 成员userid,字符串
1986 departmentid(后续将废弃) uint32 部门departmentid, 32位整型范围是[0, 2^32) (type为2时填写)
1987 watermark obj 水印相关设置(除show_visitor_name字段外,其余字段仅文档可设置)
1988 text string 水印文字,此字段不填则保持原样
1989 margin_type uint32 水印类型。1:低密度水印, 2: 高密度水印,此字段不填则保持原样
1990 show_visitor_name bool 是否显示访问人名称,此字段不填则保持原样(仅专业版支持)
1991 force_by_admin bool 管理员是否强制要求使用水印,此字段不填则保持原样
1992 show_text bool 是否展示水印文本,此字段不填则保持原样
1993 force_by_space_admin bool 空间管理员是否强制要求使用水印,此字段不填则保持原样
1994
1995 =cut
1996
1997 sub get_file_permission {
1998 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
1999 my $access_token = $_[0];
2000 my $json = $_[1];
2001 my $ua = LWP::UserAgent->new;
2002 $ua->timeout(30);
2003 $ua->env_proxy;
2004
2005 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/get_file_permission?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
2006 if ($response->is_success) {
2007 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
2008 }
2009
2010 }
2011 return 0;
2012 }
2013
2014 =head2 file_secure_setting(access_token, hash);
2015
2016 修改文件安全设置
2017 最后更新:2022/12/01
2018
2019 =head2 SYNOPSIS
2020
2021 L<https://developer.work.weixin.qq.com/document/path/97892>
2022
2023 =head3 请求说明:
2024
2025 该接口用于修改文件安全设置,水印相关设置。
2026
2027 =head4 请求包结构体为:
2028
2029 {
2030 "fileid": "FILEID",
2031 "watermark": {
2032 "text": "WATERMARK_TEXT",
2033 "margin_type": 0,
2034 "show_visitor_name": false,
2035 "show_text": false,
2036 }
2037 }
2038
2039 =head4 参数说明:
2040
2041 参数 类型 是否必须 说明
2042 fileid string 是 文件fileid
2043 text string 否 水印文字,此字段不填则保持原样
2044 margin_type uint32 否 水印类型。1:低密度水印, 2: 高密度水印,此字段不填则保持原样
2045 show_visitor_name bool 否 是否显示访问人名称,此字段不填则保持原样
2046 show_text bool 否 是否展示水印文本,此字段不填则保持原样
2047
2048 =head4 权限说明:
2049
2050 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?)
2051 第三方应用需具有“微盘”权限
2052 代开发自建应用需具有“微盘”权限
2053
2054 =head3 RETURN 返回结果:
2055
2056 {
2057 "errcode": 0,
2058 "errmsg": "ok"
2059 }
2060
2061 =head4 RETURN 参数说明:
2062
2063 参数 类型 说明
2064 errcode int32 错误码
2065 errmsg string 错误码说明
2066
2067 =cut
2068
2069 sub file_secure_setting {
2070 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
2071 my $access_token = $_[0];
2072 my $json = $_[1];
2073 my $ua = LWP::UserAgent->new;
2074 $ua->timeout(30);
2075 $ua->env_proxy;
2076
2077 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_secure_setting?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
2078 if ($response->is_success) {
2079 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
2080 }
2081
2082 }
2083 return 0;
2084 }
2085
2086 =head1 FUNCTION
2087
2088 版本和容量管理
2089 最后更新:2022/07/05
2090
2091 =head2 mng_pro_info(access_token, hash);
2092
2093 获取盘专业版信息
2094
2095 =head2 SYNOPSIS
2096
2097 L<https://developer.work.weixin.qq.com/document/path/95856#获取盘专业版信息>
2098
2099 =head3 请求说明:
2100
2101 该接口用于获取专业版信息。
2102
2103 =head4 请求包结构体为:
2104
2105 {
2106 "userid": "USERID"
2107 }
2108
2109 =head4 参数说明:
2110
2111 参数 类型 是否必须 说明
2112 userid string 是 操作者userid
2113
2114 =head4 权限说明:
2115
2116 企业需要使用“微盘”secret所获取的accesstoken来调用(accesstoken如何获取?)
2117 第三方应用需具有“微盘”权限
2118 代开发自建应用需具有“微盘”权限
2119
2120 =head3 RETURN 返回结果:
2121
2122 {
2123 "errcode": 0,
2124 "errmsg": "ok",
2125 "is_pro": true,
2126 "total_vip_acct_num": 10,
2127 "use_vip_acct_num": 5,
2128 "pro_expire_time": 1754827419
2129 }
2130
2131 =head4 RETURN 参数说明:
2132
2133 参数 类型 说明
2134 errcode int32 错误码
2135 errmsg string 错误码说明
2136 is_pro bool true为专业版,false为不是专业版
2137 total_vip_acct_num uint32 总的vip账号数量
2138 use_vip_acct_num uint32 已的vip账号数量
2139 pro_expire_time uint32 专业版到期时间,时间戳,精确到秒
2140
2141 =cut
2142
2143 sub mng_pro_info {
2144 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
2145 my $access_token = $_[0];
2146 my $json = $_[1];
2147 my $ua = LWP::UserAgent->new;
2148 $ua->timeout(30);
2149 $ua->env_proxy;
2150
2151 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/mng_pro_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
2152 if ($response->is_success) {
2153 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
2154 }
2155
2156 }
2157 return 0;
2158 }
2159
2160 =head2 mng_capacity(access_token, hash);
2161
2162 获取盘容量信息
2163
2164 =head2 SYNOPSIS
2165
2166 L<https://developer.work.weixin.qq.com/document/path/95856#获取盘容量信息>
2167
2168 =head3 请求说明:
2169
2170 该接口用于获取盘容量信息。
2171
2172 =head4 请求包结构体为:
2173
2174 {
2175 }
2176
2177 =head4 参数说明:
2178
2179 参数 类型 是否必须 说明
2180
2181 =head4 权限说明:
2182
2183 企业需要使用“微盘”secret所获取的accesstoken来调用(accesstoken如何获取?)
2184 第三方应用需具有“微盘”权限
2185 代开发自建应用需具有“微盘”权限
2186
2187 =head3 RETURN 返回结果:
2188
2189 {
2190 "errcode": 0,
2191 "errmsg": "ok",
2192 "total_capacity_for_all": 22666689904640,
2193 "total_capacity_for_vip": 22300038149020,
2194 "rest_capacity_for_all": 0,
2195 "rest_capacity_for_vip": 0
2196 }
2197
2198 =head4 RETURN 参数说明:
2199
2200 参数 类型 说明
2201 errcode int32 错误码
2202 errmsg string 错误码说明
2203 total_capacity_for_all uint64 全员容量总数,单位是B
2204 total_capacity_for_vip uint64 专业容量总数,单位是B
2205 rest_capacity_for_all uint64 全员容量可用总数,单位是B(第三方不返回该字段)
2206 rest_capacity_for_vip uint64 专业容量可用总数,单位是B(第三方不返回该字段)
2207
2208 =cut
2209
2210 sub mng_capacity {
2211 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
2212 my $access_token = $_[0];
2213 my $json = $_[1];
2214 my $ua = LWP::UserAgent->new;
2215 $ua->timeout(30);
2216 $ua->env_proxy;
2217
2218 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedrive/mng_capacity?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
2219 if ($response->is_success) {
2220 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
2221 }
2222
2223 }
2224 return 0;
2225 }
2226
2227 1;
2228 __END__