Android上的一些上传文件大小问题
我试图将文件上载到samba。Android上的一些上传文件大小问题,android,file-upload,upload,Android,File Upload,Upload,我试图将文件上载到samba。 因为Android上的限制缓冲区只有16mb左右,所以我分为10mb。 下面是我的上传代码: try { int TempLength = 10 * 1024 * 1024; SmbFile file = new SmbFile(url, auth); SmbFileOutputStream out = new SmbFileOutputStream(file); File LocalFile = new File("filep
因为Android上的限制缓冲区只有16mb左右,所以我分为10mb。
下面是我的上传代码:
try {
int TempLength = 10 * 1024 * 1024;
SmbFile file = new SmbFile(url, auth);
SmbFileOutputStream out = new SmbFileOutputStream(file);
File LocalFile = new File("filepath");
FileInputStream fis = new FileInputStream(LocalFile);
byte[] buffer = new byte[TempLength];
int length = -1;
while((length = fileInputStream.read(buffer)) != -1) {
out.write(buffer);
out.flush();
}
out.close();
fis.close();
}
catch (Exception e) {
e.printStackTrace();
}
我尝试上传文件。它可以成功上载,但文件大小将出错。
例如,如果我上传一个15mb的文件,上传的文件大小将显示20mb。
我怎样才能修好它 尝试
out.write(缓冲区,0,长度)代码>