1 Star 0 Fork 0

lanfen100 / fastDFS demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
UploadLocalFileSender.java 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
已废弃 提交于 2014-10-10 10:42 . fastDFS demo
/**
* Copyright (C) 2008 Happy Fish / YuQing
*
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
* General Public License (LGPL).
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
*/
package org.csource.fastdfs.test;
import java.io.*;
import java.util.*;
import java.net.*;
import org.csource.fastdfs.*;
/**
* upload file callback class, local file sender
* @author Happy Fish / YuQing
* @version Version 1.0
*/
public class UploadLocalFileSender implements UploadCallback
{
private String local_filename;
public UploadLocalFileSender(String szLocalFilename)
{
this.local_filename = szLocalFilename;
}
/**
* send file content callback function, be called only once when the file uploaded
* @param out output stream for writing file content
* @return 0 success, return none zero(errno) if fail
*/
public int send(OutputStream out) throws IOException
{
FileInputStream fis;
int readBytes;
byte[] buff = new byte[256 * 1024];
fis = new FileInputStream(this.local_filename);
try
{
while ((readBytes=fis.read(buff)) >= 0)
{
if (readBytes == 0)
{
continue;
}
out.write(buff, 0, readBytes);
}
}
finally
{
fis.close();
}
return 0;
}
}
1
https://gitee.com/lanfen100/fastDFS-demo.git
git@gitee.com:lanfen100/fastDFS-demo.git
lanfen100
fastDFS-demo
fastDFS demo
master

搜索帮助