Fix how file size is calculated if not provided

Currently if there is no file size provided, InputStream.available()
is used to guess how many bytes are available. According to the
java documentation, available() should not be used to calculate
file sizes, as it isn't guarenteed to return the total number of
bytes in the stream. This is fixed by reading the stream to
calculate the length, then resetting the stream.

Bug: 29334784
Change-Id: Ic851c46d053157e4d5404352d76f9ff87a509607
2 files changed