File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
apps/workflowengine/lib/Check Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -57,23 +57,36 @@ public function validateCheck($operator, $value): void {
5757 }
5858 }
5959
60+ /**
61+ * Gets the file size from HTTP headers.
62+ *
63+ * Checks 'OC-Total-Length' first; if unavailable and the method is POST or PUT,
64+ * checks 'Content-Length'. Returns the size as int, float, or false if not found or invalid.
65+ *
66+ * @return int|float|false File size in bytes, or false if unavailable.
67+ */
6068 protected function getFileSizeFromHeader (): int |float |false {
69+ // Already have it cached?
6170 if ($ this ->size !== null ) {
6271 return $ this ->size ;
6372 }
6473
6574 $ size = $ this ->request ->getHeader ('OC-Total-Length ' );
6675 if ($ size === '' ) {
67- if (in_array ($ this ->request ->getMethod (), ['POST ' , 'PUT ' ])) {
76+ // Try fallback for upload methods
77+ $ method = $ this ->request ->getMethod ();
78+ if (in_array ($ method , ['POST ' , 'PUT ' ], true )) {
6879 $ size = $ this ->request ->getHeader ('Content-Length ' );
6980 }
7081 }
7182
72- if ($ size === '' || !is_numeric ($ size )) {
73- $ size = false ;
83+ if ($ size !== '' && is_numeric ($ size )) {
84+ $ this ->size = Util::numericToNumber ($ size );
85+ } else {
86+ // No valid size header found
87+ $ this ->size = false ;
7488 }
7589
76- $ this ->size = Util::numericToNumber ($ size );
7790 return $ this ->size ;
7891 }
7992
You can’t perform that action at this time.
0 commit comments