mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
commit
deacae9dd7
@ -78,12 +78,13 @@ public class GridFsManager {
|
|||||||
public void download(File targetFile, String bucketName, String fileName) throws IOException {
|
public void download(File targetFile, String bucketName, String fileName) throws IOException {
|
||||||
if (available()) {
|
if (available()) {
|
||||||
GridFSBucket bucket = getBucket(bucketName);
|
GridFSBucket bucket = getBucket(bucketName);
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
try (GridFSDownloadStream gis = bucket.openDownloadStream(fileName);
|
try (GridFSDownloadStream gis = bucket.openDownloadStream(fileName);
|
||||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(targetFile))
|
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(targetFile))
|
||||||
) {
|
) {
|
||||||
while (gis.read(buffer) != -1) {
|
byte[] buffer = new byte[1024];
|
||||||
bos.write(buffer);
|
int bytes = 0;
|
||||||
|
while ((bytes = gis.read(buffer)) != -1) {
|
||||||
|
bos.write(buffer, 0, bytes);
|
||||||
}
|
}
|
||||||
bos.flush();
|
bos.flush();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user