i have found this code HttpURLConnection to Send image , audio and video files with parameter may (String or Json String) Android and it works perfectly with video, images and audio. But when i send a large video i get this error :
Throwing OutOfMemoryError "Failed to allocate a 28 byte allocation with 0 free bytes and -1856B until OOM" (recursive case)
The video is simply too large to work with in RAM all at once, so you'll either need to make the file smaller, or work with it in pieces, in which case your server will need to be configured to accept chunks of streamed data as well. From the HttpURLConnection
docs:
To upload data to a web server, configure the connection for output using setDoOutput(true). For best performance, you should call either setFixedLengthStreamingMode(int) when the body length is known in advance, or setChunkedStreamingMode(int) when it is not. Otherwise HttpURLConnection will be forced to buffer the complete request body in memory before it is transmitted, wasting (and possibly exhausting) heap and increasing latency.
So setting setChunkedStreamingMode()
might solve your issue.
Also you might take a look at this question: Upload large file in Android without outofmemory error