| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.nio.file.Paths; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import com.ltkj.common.config.ltkjConfig; |
| | |
| | | } |
| | | return extension; |
| | | } |
| | | |
| | | public static Map<String, String> getFileSize(MultipartFile file) throws IOException { |
| | | long fileSizeBytes = file.getSize(); |
| | | double fileSizeMB = fileSizeBytes / (1024.0 * 1024.0); |
| | | double fileSizeGB = fileSizeBytes / (1024.0 * 1024.0 * 1024.0); |
| | | String fileSizeMBStr = String.format("%.2f MB", fileSizeMB); |
| | | String fileSizeGBStr = String.format("%.2f GB", fileSizeGB); |
| | | Map<String, String> result = new HashMap<>(); |
| | | result.put("fileSizeBytes", fileSizeBytes + " Bytes"); |
| | | result.put("fileSizeMB", fileSizeMBStr); |
| | | result.put("fileSizeGB", fileSizeGBStr); |
| | | return result; |
| | | } |
| | | } |