【问题标题】:how to upload bin file from android internal storage to http server in android如何将bin文件从android内部存储上传到android中的http服务器
【发布时间】:2018-06-04 05:39:26
【问题描述】:

如何将bin文件从内部存储上传到android中的http服务器?

我收到权限被拒绝错误。

        String url = "url_path";
        String PATH = "/storage/emulated/0/data/";
        Log.v("response path ", "PATH: " + PATH);
        File file = new File(PATH,
                "/test.bin");
        if(file.exists()){
            Log.d("response : "," file available");
        } else {
            Log.d("response : "," file not available");
        }
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(url);
        InputStreamEntity reqEntity = new InputStreamEntity(
                new FileInputStream(file), -1);
        reqEntity.setContentType("binary/octet-stream");
        reqEntity.setChunked(true); // Send in multiple parts if needed
        httppost.setEntity(reqEntity);
        HttpResponse response = httpclient.execute(httppost);

错误日志:

java.io.FileNotFoundException: /storage/emulated/0/data/test.bin(权限被拒绝)

【问题讨论】:

    标签: android httpserver bin internal-storage


    【解决方案1】:

    您只有应用程序的数据目录的权限。除非您有 android 设备。

    系统应用。

    【讨论】:

      猜你喜欢
      • 2011-06-25
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多