Class FileDownloadUtil
java.lang.Object
ru.vyarus.dropwizard.guice.test.client.util.FileDownloadUtil
File download from response utility.
- Since:
- 09.10.2025
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathDownload a file from the response.static @Nullable StringparseFileName(jakarta.ws.rs.core.Response response) Less accurate version ofreadFilename(Response)with simplified header parsing.static StringparseFileName(String header) Less accurate version ofreadFilename(Response)with simplified header parsing.static @Nullable StringreadFilename(jakarta.ws.rs.core.Response response) Use jersey header parser when the multipart jar is available.static PathsaveFile(String name, InputStream input, Path dir) Save file from input stream to target directory.
-
Method Details
-
download
Download a file from the response.Limitation: does not support multipart responses. Use
parseFileName(String)andsaveFile(String, InputStream, Path)manually directly for multipart chunks.- Parameters:
response- response objectdir- target directory to save the file in- Returns:
- downloaded ile
-
saveFile
Save file from input stream to target directory. If a file with the same name already exists, an index will be added to the name.- Parameters:
name- file name (could be without extension)input- file input streamdir- target directory- Returns:
- downloaded file
-
readFilename
Use jersey header parser when the multipart jar is available. Otherwise, fallback to less accurate manual parsing.- Parameters:
response- response object to read header from- Returns:
- file name from content-disposition header or null if header not found
-
parseFileName
Less accurate version ofreadFilename(Response)with simplified header parsing. Used when the multipart jar is not available (and so jersey native parsing can't be used).- Parameters:
response- response object to read header from- Returns:
- file name from content-disposition header or null if header not found
-
parseFileName
Less accurate version ofreadFilename(Response)with simplified header parsing. Used when the multipart jar is not available (and so jersey native parsing can't be used).- Parameters:
header- content-disposition header- Returns:
- parsed file name
-