java - HttpURLConnection Bad Gateway: 502 error -


I have a server to get the media JPG format and MP4 format. Delivery is through the HttpURL connection as far as I understand - this is the best solution for working with http and https file transfer. This code is trying to work through http:

  FileInputStream fileInputStream = new FileInputStream (new file (sourceFileUri)); URL url = new URL (upload URL); Connection = (HttpURL connection) url.openConnection (); Connection.setDoInput (true); Connection.setDoOutput (true); Connection.setUseCaches (wrong); Connection.setRequestMethod ("post"); Connection.setRequestProperty ("Connection", "Keep-Elive"); Connection.setRequestProperty ("content-type", "multipart / form-data; limit =" + limit); Outputstream = new dataoutputstream (connection.getOutputStream ()); OutputStreamLitebites (Two Hippens + Boundary + Lineand); Outputstream.writebytes ("content-disposition: form-data; name = \" uploaded file \ "; filename = \" "+ sourceFileUri +" \ "" + lineEnd); OutputStream.writeBytes (lineEnd); Bytes available = fileInputStream.available (); Buffer size = math (Bytes available, maxbuffer size); Buffer = new byte [buffer size]; BytesRed = FileInputStream Read (buffer, 0, buffer size); Log D. (Tag, string.value (bytes read)); While (bytes read> 0) {outputstream.write (buffer, 0, buffer size); Bytes available = fileInputStream.available (); Buffer size = math (Bytes available, maxbuffer size); BytesRed = FileInputStream Read (buffer, 0, buffer size); } Outputstream.writeBytes (lineand); OutputStreamLitebites (Two Hpens + Border + TwoHipes + Lineand); FileInputStream.close (); OutputStream.close (); File inputstream fileInputStream = new fileInstream (new file (source file Yuri)); URL url = new URL (upload URL); Connection = (HttpURL connection) url.openConnection (); Connection.setDoInput (true); Connection.setDoOutput (true); Connection.setUseCaches (wrong); Connection.setRequestMethod ("post"); Connection.setRequestProperty ("Connection", "Keep-Elive"); Connection.setRequestProperty ("content-type", "multipart / form-data; limit =" + limit); Outputstream = new dataoutputstream (connection.getOutputStream ()); OutputStreamLitebites (Two Hippens + Boundary + Lineand); Outputstream.writebytes ("content-disposition: form-data; name = \" uploaded file \ "; filename = \" "+ sourceFileUri +" \ "" + lineEnd); OutputStream.writeBytes (lineEnd); Bytes available = fileInputStream.available (); Buffer size = math (Bytes available, maxbuffer size); Buffer = new byte [buffer size]; BytesRed = FileInputStream Read (buffer, 0, buffer size); Log D. (Tag, string.value (bytes read)); While (bytes read> 0) {outputstream.write (buffer, 0, buffer size); Bytes available = fileInputStream.available (); Buffer size = math (Bytes available, maxbuffer size); BytesRed = FileInputStream Read (buffer, 0, buffer size); } Outputstream.writeBytes (lineand); OutputStreamLitebites (Two Hpens + Border + TwoHipes + Lineand); FileInputStream.close (); OutputStream.close ();  

Once I record the incoming bit stream file, I get a server error "502 Bad Gateway". What's wrong in this part of the code? I'm looking for a problem for 5 hours but nothing was found.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -