|
|
@@ -64,10 +64,19 @@ public class FileService {
|
|
|
String fileType = FileHelper.getFileType(filename);
|
|
|
File file = FileHelper.multipartToFile(inFile);
|
|
|
log.info("server file location: " + file.getAbsolutePath());
|
|
|
- int rsl = "csv".equals(fileType) ? csvLoader.loadCsv(file.getAbsolutePath(), userId) :
|
|
|
- sasLoader.loadSas(file.getAbsolutePath(), userId);
|
|
|
- file.delete();
|
|
|
- return rsl;
|
|
|
+ try{
|
|
|
+// return "csv".equals(fileType) ? csvLoader.loadCsv(file.getAbsolutePath(), userId) :
|
|
|
+// sasLoader.loadSas(file.getAbsolutePath(), userId);
|
|
|
+ //数据库中不能用同名文件
|
|
|
+ if (fileInfoDao.findByUserIdAndFilename(userId,filename)!=null){
|
|
|
+ throw new Exception("文件已经存在了。");
|
|
|
+ }
|
|
|
+ //暂时只接受csv
|
|
|
+ return "csv".equals(fileType) ? csvAdapter.Csv2Parquet(file.getAbsolutePath(), filename, userId) : 0;
|
|
|
+ }finally {
|
|
|
+ //上传失败也必须将文件在本地删除,否则会堆积
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void deleteFile(int fileId) throws Exception {
|