13
13
*
14
14
* @link https://waifuvault.moe/
15
15
*
16
- * @phpstan-type FileUpload array{
17
- * file: string,
18
- * filename?: string
19
- * }
20
- * @phpstan-type FileContentUpload array{
21
- * file_contents: string,
22
- * filename: string
23
- * }
24
- * @phpstan-type UrlUpload array{
25
- * url: string
26
- * }
27
- *
28
16
* @phpstan-type uploadFileArg array{
17
+ * file?: string,
18
+ * url?: string,
19
+ * filename?: string,
20
+ * file_contents?: string,
29
21
* expires?:string,
30
22
* hide_filename?:bool,
31
23
* password?:string,
32
24
* one_time_download?:bool
33
- * }&(FileUpload|FileContentUpload|UrlUpload)
25
+ * }
34
26
*
35
27
* @phpstan-type modifyFileArg array{
36
28
* token: string,
@@ -69,7 +61,6 @@ function ($v, $k) {
69
61
return in_array ($ k , array (
70
62
'expires ' ,
71
63
'hide_filename ' ,
72
- 'password ' ,
73
64
'one_time_download ' )) && !is_null ($ v ); // @phpstan-ignore-line
74
65
},
75
66
ARRAY_FILTER_USE_BOTH
@@ -79,7 +70,7 @@ function ($v, $k) {
79
70
* http_build_query will convert them to 1 or 0 integers, which throws an API Exception
80
71
*/
81
72
$ params = http_build_query (array_map (
82
- fn ($ v )=>is_bool ($ v ) ? ($ v ? 'true ' : 'false ' ) : $ v , // @phpstan-ignore-line
73
+ fn ($ v )=>is_bool ($ v ) ? ($ v ? 'true ' : 'false ' ) : $ v ,
83
74
$ params
84
75
));
85
76
if ($ params !== '' ) {
@@ -99,13 +90,16 @@ function ($v, $k) {
99
90
}
100
91
$ post_fields ['file ' ] = new CURLStringFile ($ data , $ file_name );
101
92
} elseif (isset ($ args ['file_contents ' ])) {
102
- if (!isset ($ args ['filename ' ]) || $ args ['filename ' ] === '' ) { // @phpstan-ignore-line
93
+ if (!isset ($ args ['filename ' ]) || $ args ['filename ' ] === '' ) {
103
94
throw new Exception ('File name is missing. ' );
104
95
}
105
96
$ post_fields ['file ' ] = new CURLStringFile ($ args ['file_contents ' ], $ args ['filename ' ]);
106
97
} else {
107
98
throw new Exception ('Please provide a url, file or file_contents. ' );
108
99
}
100
+ if (isset ($ args ['password ' ]) && $ args ['password ' ] !== '' ) {
101
+ $ post_fields ['password ' ] = $ args ['password ' ];
102
+ }
109
103
return $ this ->requestHandler ->make (
110
104
RequestMethods::PUT ,
111
105
$ url ,
0 commit comments