I want to show uploading file size during web service. So I have used the following two links HttpClient Post with progress and MultipartEntityBuilder, gradle-hockeyapp-plugin where i found the ProgressHttpEntityWrapper.java
class. Using this class I have found the uploading file size. Using the below method
public String getFileSize(long size) {
if (size <= 0)
return "0";
final String[] units = new String[] { mContext.getResources().getString(R.string.bytes), mContext.getResources().getString(R.string.kilo_bytes), mContext.getResources().getString(R.string.mega_bytes), mContext.getResources().getString(R.string.giga_bytes), mContext.getResources().getString(R.string.tera_bytes) };
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
but it gives wrong file size compare than the original file size. Both actual and uploading total file sizes vary.
For example, my actual file size 297.1 KB but it show the total file size is 365.5 KB. Why the actual file size and uploaing total file size gets vary. Could you please suggest me any idea?