fix: use Files.copy in FileuploadService to support video and large file uploads
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.realnet.FileUpload.Services;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -43,17 +44,11 @@ public class FileuploadService {
|
||||
|
||||
|
||||
}
|
||||
// reading data
|
||||
InputStream is = multipartFile.getInputStream();
|
||||
byte data[] = new byte[is.available()];
|
||||
is.read(data);
|
||||
|
||||
// writing data
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(filepath);
|
||||
fos.write(data);
|
||||
fos.close();
|
||||
fos.flush();
|
||||
// save file
|
||||
File dest = new File(filepath);
|
||||
try (InputStream is = multipartFile.getInputStream()) {
|
||||
Files.copy(is, dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
f = true;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user