您好我要上传我的视频文件成Android的Web服务器。我跟着这个教程:
Hi I want to upload my video file into web server in Android. I followed this tutorial:
将文件上载到使用POST Android上的HTTP服务器。
不过。我在logcat中得到这个错误。我得到一个消息服务器了。
But. I got this error in my logcat. And i got a message from server too.
09-11 10:20:55.088: D/dalvikvm(284): GC_FOR_MALLOC freed 1137 objects / 74200 bytes in 70ms
09-11 10:20:55.768: I/dalvikvm-heap(284): Grow heap (frag case) to 3.611MB for 1048592-byte allocation
09-11 10:20:55.918: D/dalvikvm(284): GC_FOR_MALLOC freed 202 objects / 10144 bytes in 142ms
09-11 10:20:56.178: D/dalvikvm(284): GC_FOR_MALLOC freed 86 objects / 3424 bytes in 91ms
09-11 10:20:56.568: I/dalvikvm-heap(284): Grow heap (frag case) to 5.601MB for 2097364-byte allocation
09-11 10:20:56.868: D/dalvikvm(284): GC_FOR_MALLOC freed 2 objects / 56 bytes in 304ms
09-11 10:20:57.178: D/dalvikvm(284): GC_FOR_MALLOC freed 4 objects / 1120 bytes in 48ms
09-11 10:20:57.748: I/dalvikvm-heap(284): Grow heap (frag case) to 11.600MB for 6291668-byte allocation
09-11 10:20:57.918: D/dalvikvm(284): GC_FOR_MALLOC freed 0 objects / 0 bytes in 168ms
09-11 10:21:24.827: I/uploadFile(284): HTTP Response is : OK: 200
09-11 10:21:24.847: E/Debug(284): Server Response There was an error uploading the file, please try again!
09-11 10:21:24.858: I/System.out(284): RES : 200
09-11 10:21:24.997: WARN/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44ff6cc8
09-11 10:23:34.277: DEBUG/SntpClient(59): request time failed: java.net. Socket Exception: Address family not supported by protocol
按照此过程中,我要上传的视频文件为wowza媒体服务器。我怎样才能解决这个问题。以及如何着手wowza服务器?任何人可以帮助我实现这一目标? 先谢谢了。
Follow this process i want upload video file into wowza media server. How can i resolve this. And how can i proceed in wowza server? Can anybody help me to achieve this? Thanks in advance.
从字节的视频发送到服务器的[]可能会造成的OutOfMemoryError所以它能够更好地发布视频的上传。你可以从这个链接下载jar文件。 http://hc.apache.org/downloads.cgi 。下载并添加httpmime-4.2.jar到您的项目。
Sending video to server from byte[] may cause outOfMemoryError so its better to post video from MultiPart. You can download jar file from this link. http://hc.apache.org/downloads.cgi . Download and add httpmime-4.2.jar to your project.
public void uploadVideo(Context context, String videoPath) {
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(context.getString(R.string.url_service_fbpost));
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
if(!videoPath.isEmpty()){
FileBody filebodyVideo = new FileBody(new File(videoPath));
reqEntity.addPart("uploaded", filebodyVideo);
}
postRequest.setEntity(reqEntity);
HttpResponse response = httpClient.execute(postRequest);
BufferedReader reader = new BufferedReader(new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
while ((sResponse = reader.readLine()) != null) {
s = s.append(sResponse);
}
Log.e("Response: ", s.toString());
return true;
} catch (Exception e) {
Log.e(e.getClass().getName(), e.getMessage());
return false;
}
}