从Android上传大型视频文件

时间:2014-04-23 13:38:51

标签: java android

我无法将大型视频上传到服务器android? 我尝试使用这种方法

private void UploadLargeFile(String[] args) throws Exception {
    CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
try {
    httpclient.start();
    File upload = new File(args[0]);
    File download = new File(args[1]);
    ZeroCopyPost httpost = null;
    try {
        httpost = new ZeroCopyPost(URLTOUploadFile", upload,
                ContentType.create("video/mp4"));
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    ZeroCopyConsumer<File> consumer = null;
    consumer = new ZeroCopyConsumer<File>(download) {

        @Override
        protected File process(final HttpResponse response,
                final File file, final ContentType contentType)
                throws Exception {
            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
                throw new ClientProtocolException("Upload failed: "
                        + response.getStatusLine());
            }
            return file;
        }

    };
    Future<File> future = httpclient.execute(httpost, consumer, null);
    File result;            
    result = future.get();
    System.out.println("Response file length: " + result.length());
    System.out.println("Shutting down");
} finally {
    httpclient.close();
}
System.out.println("Done");

}

在CloseableHttpAsyncClient的第一行中我得到NoSuchFieldFound错误 任何人都可以帮助我吗?

0 个答案:

没有答案