我需要使用http服务调用将视频上传到服务器。
为此,我有一个如下服务电话。
我如何获得大量字节传入" chunk"服务电话中的参数。?
这是我的代码
int mychunkSize = 100 * 1024;
realPath = getRealPathFromURI(videoFileUri);
System.out.println("file name" + realPath);
long size1 = realPath.length();
size = Long.toString(size1);
System.out.println("total size" + size);
long chunks1 = size1 < mychunkSize ? 1
: (realPath.length() / mychunkSize);
chunks = Long.toString(chunks1);
这是获取大块字节(块)的正确方法吗?
请帮助..
答案 0 :(得分:2)
使用multipart上传
Uploading large files from android to c# WCF Rest Service
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("FileData", new FileBody(file));
httppost.setEntity(entity);
HttpResponse response = httpclient.execute(httppost);
String responseData = EntityUtils.toString(response.getEntity());