mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
int to long
This commit is contained in:
@@ -2,9 +2,9 @@ package cn.hutool.core.net.multipart;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.multi.ListValueMap;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -78,10 +78,7 @@ public class MultipartFormData {
|
||||
putFile(header.formFieldName, newFile);
|
||||
} else {
|
||||
// 标准表单项
|
||||
ByteArrayOutputStream fbos = new ByteArrayOutputStream(1024);
|
||||
input.copy(fbos);
|
||||
String value = (charset != null) ? new String(fbos.toByteArray(), charset) : new String(fbos.toByteArray());
|
||||
putParameter(header.formFieldName, value);
|
||||
putParameter(header.formFieldName, IoUtil.read(input, charset));
|
||||
}
|
||||
|
||||
input.skipBytes(1);
|
||||
|
@@ -171,7 +171,7 @@ public class MultipartRequestInputStream extends BufferedInputStream {
|
||||
* @return 复制的字节数
|
||||
* @throws IOException 读取异常
|
||||
*/
|
||||
public int copy(OutputStream out, int limit) throws IOException {
|
||||
public int copy(OutputStream out, long limit) throws IOException {
|
||||
int count = 0;
|
||||
while (true) {
|
||||
byte b = readByte();
|
||||
|
@@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -24,7 +23,7 @@ public class UploadFile {
|
||||
private final UploadFileHeader header;
|
||||
private final UploadSetting setting;
|
||||
|
||||
private int size = -1;
|
||||
private long size = -1;
|
||||
|
||||
// 文件流(小文件位于内存中)
|
||||
private byte[] data;
|
||||
@@ -150,7 +149,7 @@ public class UploadFile {
|
||||
/**
|
||||
* @return 上传文件的大小,> 0 表示未上传
|
||||
*/
|
||||
public int size() {
|
||||
public long size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -200,13 +199,13 @@ public class UploadFile {
|
||||
|
||||
// 处理硬盘文件
|
||||
tempFile = FileUtil.createTempFile(TMP_FILE_PREFIX, TMP_FILE_SUFFIX, FileUtil.touch(setting.tmpUploadPath), false);
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
|
||||
final BufferedOutputStream out = FileUtil.getOutputStream(this.tempFile);
|
||||
if (data != null) {
|
||||
size = data.length;
|
||||
out.write(data);
|
||||
data = null; // not needed anymore
|
||||
}
|
||||
int maxFileSize = setting.maxFileSize;
|
||||
final long maxFileSize = setting.maxFileSize;
|
||||
try {
|
||||
if (maxFileSize == -1) {
|
||||
size += input.copy(out);
|
||||
@@ -236,14 +235,14 @@ public class UploadFile {
|
||||
* @return 是否为允许的扩展名
|
||||
*/
|
||||
private boolean isAllowedExtension() {
|
||||
String[] exts = setting.fileExts;
|
||||
final String[] exts = setting.fileExts;
|
||||
boolean isAllow = setting.isAllowFileExts;
|
||||
if (exts == null || exts.length == 0) {
|
||||
// 如果给定扩展名列表为空,当允许扩展名时全部允许,否则全部禁止
|
||||
return isAllow;
|
||||
}
|
||||
|
||||
String fileNameExt = FileUtil.extName(this.getFileName());
|
||||
final String fileNameExt = FileUtil.extName(this.getFileName());
|
||||
for (String fileExtension : setting.fileExts) {
|
||||
if (fileNameExt.equalsIgnoreCase(fileExtension)) {
|
||||
return isAllow;
|
||||
|
@@ -31,7 +31,8 @@ public class UploadFileHeader {
|
||||
// ---------------------------------------------------------------- public interface
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if uploaded data are correctly marked as a file. This is true if header contains string 'filename'.
|
||||
* Returns {@code true} if uploaded data are correctly marked as a file.<br>
|
||||
* This is true if header contains string 'filename'.
|
||||
*
|
||||
* @return 是否为文件
|
||||
*/
|
||||
|
@@ -9,7 +9,7 @@ package cn.hutool.core.net.multipart;
|
||||
public class UploadSetting {
|
||||
|
||||
/** 最大文件大小,默认无限制 */
|
||||
protected int maxFileSize = -1;
|
||||
protected long maxFileSize = -1;
|
||||
/** 文件保存到内存的边界 */
|
||||
protected int memoryThreshold = 8192;
|
||||
/** 临时文件目录 */
|
||||
@@ -26,7 +26,7 @@ public class UploadSetting {
|
||||
/**
|
||||
* @return 获得最大文件大小,-1表示无限制
|
||||
*/
|
||||
public int getMaxFileSize() {
|
||||
public long getMaxFileSize() {
|
||||
return maxFileSize;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class UploadSetting {
|
||||
*
|
||||
* @param maxFileSize 最大文件大小
|
||||
*/
|
||||
public void setMaxFileSize(int maxFileSize) {
|
||||
public void setMaxFileSize(long maxFileSize) {
|
||||
this.maxFileSize = maxFileSize;
|
||||
}
|
||||
|
||||
|
@@ -83,6 +83,8 @@ public class IdcardUtil {
|
||||
CITY_CODES.put("71", "台湾");
|
||||
CITY_CODES.put("81", "香港");
|
||||
CITY_CODES.put("82", "澳门");
|
||||
//issue#1277,台湾身份证号码以83开头,但是行政区划为71
|
||||
CITY_CODES.put("83", "台湾");
|
||||
CITY_CODES.put("91", "国外");
|
||||
|
||||
TW_FIRST_CODE.put("A", 10);
|
||||
@@ -354,7 +356,7 @@ public class IdcardUtil {
|
||||
sum = sum + Integer.parseInt(String.valueOf(c)) * iflag;
|
||||
iflag--;
|
||||
}
|
||||
if ("A".equals(end.toUpperCase())) {
|
||||
if ("A".equalsIgnoreCase(end)) {
|
||||
sum += 10;
|
||||
} else {
|
||||
sum += Integer.parseInt(end);
|
||||
|
Reference in New Issue
Block a user