Skip to content

Commit 4258da8

Browse files
committed
INT-3746: RemoteFileTemplate streaming backport
Resolves https://jira.spring.io/browse/INT-3746
1 parent f2bd8c4 commit 4258da8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

spring-integration-file/src/main/java/org/springframework/integration/file/remote/RemoteFileTemplate.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ else if (payload instanceof byte[] || payload instanceof String) {
494494
}
495495
dataInputStream = new ByteArrayInputStream(bytes);
496496
}
497+
else if (payload instanceof InputStream) {
498+
dataInputStream = (InputStream) payload;
499+
name = "InputStream payload";
500+
}
497501
else {
498502
throw new IllegalArgumentException("Unsupported payload type. The only supported payloads are " +
499503
"java.io.File, java.lang.String, and byte[]");

spring-integration-file/src/test/java/org/springframework/integration/file/remote/RemoteFileTemplateTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import static org.mockito.Mockito.verify;
2424
import static org.mockito.Mockito.when;
2525

26+
import java.io.ByteArrayInputStream;
2627
import java.io.File;
28+
import java.io.IOException;
2729
import java.io.InputStream;
2830

2931
import org.hamcrest.Matchers;
@@ -117,4 +119,12 @@ public void testIgnoreNotExists() throws Exception {
117119
verify(this.session).write(Mockito.any(InputStream.class), Mockito.anyString());
118120
}
119121

122+
@Test
123+
public void testStream() throws IOException {
124+
ByteArrayInputStream stream = new ByteArrayInputStream("foo".getBytes());
125+
this.template.send(new GenericMessage<InputStream>(stream),
126+
FileExistsMode.IGNORE);
127+
verify(this.session).write(Mockito.eq(stream), Mockito.any());
128+
}
129+
120130
}

0 commit comments

Comments
 (0)