|
@ -1,5 +1,6 @@
|
|
package com.yihu.wlyy.util.fastdfs;
|
|
package com.yihu.wlyy.util.fastdfs;
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
@ -51,7 +52,7 @@ public class FastDFSUtil {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
final static int BUFFER_SIZE = 4096;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 以输入流的方式上传文件
|
|
* 以输入流的方式上传文件
|
|
@ -90,14 +91,13 @@ public class FastDFSUtil {
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectNode message = objectMapper.createObjectNode();
|
|
ObjectNode message = objectMapper.createObjectNode();
|
|
|
|
|
|
byte fileBuffer[] = new byte[in.available()];
|
|
|
|
int len = 0;
|
|
|
|
int temp = 0; //所有读取的内容都使用temp接收
|
|
|
|
while ((temp = in.read()) != -1) { //当没有读取完时,继续读取
|
|
|
|
fileBuffer[len] = (byte) temp;
|
|
|
|
len++;
|
|
|
|
|
|
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
|
|
|
byte[] buff = new byte[BUFFER_SIZE]; //buff用于存放循环读取的临时数据
|
|
|
|
int rc = 0;
|
|
|
|
while ((rc = in.read(buff, 0, BUFFER_SIZE)) > 0) {
|
|
|
|
swapStream.write(buff, 0, rc);
|
|
}
|
|
}
|
|
in.close();
|
|
|
|
|
|
byte[] fileBuffer = swapStream.toByteArray(); //in_b为转换之后的结果
|
|
|
|
|
|
TrackerServer trackerServer = FastDFSClientPool.getInstance().getTrackerServer();
|
|
TrackerServer trackerServer = FastDFSClientPool.getInstance().getTrackerServer();
|
|
|
|
|