【发布时间】:2017-01-25 15:54:47
【问题描述】:
当我从平板电脑将100kb 的图片上传到与 JCIFS 共享的 samba 时遇到问题,大约需要 10-20 分钟(在我将缓冲区从 1024 to 20971520 更改之前花了将近 6 个小时)但是它不再产生任何增加它的效果
这不是连接问题,因为我已经使用ES File 对其进行了测试,它立即上传了我的图片
private class MyCopy extends AsyncTask<String, String, String> {
String z = "";
String username = "", password = "", servername = "", filestocopy = "";
@Override
protected void onPreExecute() {
username = edtusername.getText().toString();
password = edtpassword.getText().toString();
servername = "smb://" + edtservername.getText().toString();
filestocopy = editdir.getText().toString();
}
protected String doInBackground(String... params) {
// String buffer;
// buffer = setingPreferences.getString("buffer", "");
File file = new File(filestocopy);
String filename = file.getName();
NtlmPasswordAuthentication auth1 = new NtlmPasswordAuthentication(
servername, username, password);
try {
SmbFile sfile = new SmbFile(servername + "/" + filename, auth1);
if (!sfile.exists())
sfile.createNewFile();
sfile.connect();
InputStream in = new FileInputStream(file);
SmbFileOutputStream sfos = new SmbFileOutputStream(sfile);
byte[] buf = new byte[20971520]; //(parseInt(buffer))
int len;
while ((len = in.read(buf)) > 0){
sfos.write(buf, 0, len);
}
in.close();
sfos.close();
z = "File copied successfully";
} catch (Exception ex) {
z = z + " " + ex.getMessage().toString();
}
return z;
}
}
【问题讨论】:
-
您是否尝试过在 J2SE 环境中使用 JCIFS 来检查它是 Android 问题还是 JCIFS 只是问题?这个库似乎很旧(最后一次真正的更新是 2011 年)......
标签: android image-uploading smb jcifs