OutputStream OutOfMemoryError when sending HTTP

前端 未结 6 1757
深忆病人
深忆病人 2020-12-01 16:53

I am trying to publish a large video/image file from the local file system to an http path, but I run into an out of memory error after some time...

here is the code

6条回答
  •  醉话见心
    2020-12-01 17:08

    conn.setFixedLengthStreamingMode((int) new File(localpath).length());
    

    And for buffering you could cover your streams into the BufferedOutputStream and BufferedInputStream

    Good example of chunked uploading you could find there: gdata-java-client

提交回复
热议问题