-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for downloading list of files in REST Client
Closes: #41978
- Loading branch information
Showing
6 changed files
with
185 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/PathFileDownload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.quarkus.rest.client.reactive.multipart; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.jboss.resteasy.reactive.multipart.FileDownload; | ||
|
||
public class PathFileDownload implements FileDownload { | ||
private final String partName; | ||
private final File file; | ||
|
||
public PathFileDownload(File file) { | ||
this(null, file); | ||
} | ||
|
||
public PathFileDownload(String partName, File file) { | ||
this.partName = partName; | ||
this.file = file; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return partName; | ||
} | ||
|
||
@Override | ||
public Path filePath() { | ||
return file.toPath(); | ||
} | ||
|
||
@Override | ||
public String fileName() { | ||
return file.getName(); | ||
} | ||
|
||
@Override | ||
public long size() { | ||
try { | ||
return Files.size(file.toPath()); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to get size", e); | ||
} | ||
} | ||
|
||
@Override | ||
public String contentType() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String charSet() { | ||
return null; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
extensions/resteasy-reactive/rest-client/deployment/src/test/resources/lorem.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | ||
enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor | ||
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, | ||
sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
|
9 changes: 9 additions & 0 deletions
9
extensions/resteasy-reactive/rest-client/deployment/src/test/resources/test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- head definitions go here --> | ||
</head> | ||
<body> | ||
<!-- the content goes here --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters