【问题标题】:Some upload file size issue on AndroidAndroid上的一些上传文件大小问题
【发布时间】:2013-07-10 12:21:39
【问题描述】:

我尝试将文件上传到 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("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。
我该如何解决?

【问题讨论】:

    标签: android file-upload upload


    【解决方案1】:

    试试out.write(buffer, 0, length);

    【讨论】:

      猜你喜欢
      • 2013-05-07
      • 2011-04-08
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 2013-01-26
      • 1970-01-01
      • 2023-04-01
      相关资源
      最近更新 更多