wrong file object inject from form field into the controller param #1316 · actframework/actframework@f8019ee · GitHub
Skip to content

Commit f8019ee

Browse files
committed
wrong file object inject from form field into the controller param #1316
1 parent 1f5a76d commit f8019ee

8 files changed

Lines changed: 90 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions

‎src/main/java/act/util/UploadFileStorageService.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ private ISObject _store(FileItemStream fileItemStream) throws IOException {
8989
retVal = getFull(key);
9090
} else {
9191
int size = output.written;
92+
if (0 == size) {
93+
return null;
94+
}
9295
byte[] buf = output.buf();
9396
retVal = SObject.of(key, buf, size);
9497
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package test;
2+
3+
import org.beetl.core.Context;
4+
import org.beetl.core.Function;
5+
import org.osgl.util.S;
6+
7+
import javax.inject.Named;
8+
9+
@Named("myFunc")
10+
public class BeetlTestFunction implements Function {
11+
12+
@Override
13+
public Object call(Object[] objects, Context context) {
14+
String value = (String) objects[0];
15+
String ovalue = (String) objects[1];
16+
if(S.eq(value, ovalue, S.IGNORECASE)){
17+
return "checked";
18+
}
19+
return "";
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<head>Test</head>
3+
<body>
4+
<div>
5+
Test result1: <span id="r1">${myFunc()}</span>
6+
</div>
7+
<div>
8+
Test result2: <span id="r2">${myFunc()}</span>
9+
</div>
10+
</body>
11+
</html>

‎testapps/GHIssues/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<parent>
1313
<groupId>org.actframework</groupId>
1414
<artifactId>act-starter-parent</artifactId>
15-
<version>1.8.31.0</version>
15+
<version>1.8.32.0</version>
1616
</parent>
1717

1818
<properties>
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>org.actframework</groupId>
2727
<artifactId>act</artifactId>
28-
<version>1.8.32-SNAPSHOT</version>
28+
<version>1.8.33-SNAPSHOT</version>
2929
</dependency>
3030
<dependency>
3131
<groupId>org.actframework</groupId>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ghissues;
2+
3+
import act.controller.annotation.UrlContext;
4+
import act.util.PropertySpec;
5+
import org.osgl.mvc.annotation.GetAction;
6+
import org.osgl.mvc.annotation.PostAction;
7+
import org.osgl.util.N;
8+
import org.osgl.util.S;
9+
10+
import java.io.File;
11+
12+
import static act.controller.Controller.Util.renderTemplate;
13+
14+
@UrlContext("1316")
15+
public class Gh1316 extends BaseController {
16+
17+
@GetAction
18+
public void form() {
19+
renderTemplate("/1316.html");
20+
}
21+
22+
@PostAction()
23+
public String filetest(File[] files1, File[] files2) {
24+
if (files1.length == 0 && files2.length == 0) {
25+
return null;
26+
}
27+
return "found";
28+
}
29+
30+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<title>GH1316 form</title>
4+
</head>
5+
<body>
6+
<form action="/1316" method="post" enctype="multipart/form-data">
7+
8+
<input name="files1" type="file" multiple />
9+
<input name="files2" type="file" multiple />
10+
11+
<button type="submit">Submit</button>
12+
</form>
13+
</body>
14+
</html>
Lines changed: 8 additions & 0 deletions

0 commit comments

Comments
 (0)