java - Actual file size and uploading file size gets differ android -


i want show uploading file size during web service. have used following 2 links httpclient post progress , multipartentitybuilder, gradle-hockeyapp-plugin found progresshttpentitywrapper.java class. using class have found uploading file size. using 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 gives wrong file size compare original file size. both actual , uploading total file sizes vary.

for example, actual file size 297.1 kb show total file size 365.5 kb. why actual file size , uploaing total file size gets vary. please suggest me idea?

okay, thank response. i'm found why exact file size not returning. because assigning call entire entity below,

  progresshttpentitywrapper.progresscallback progresscallback = new progresshttpentitywrapper.progresscallback() {      @override     public void progress(float progress) {         //use progress     }  } 

in below code i'm assigning progress callback entire entity

httppost.setentity(new progresshttpentitywrapper(entitybuilder.build(), progresscallback));

where entity not contain file. contain thumbnail file , other params. size gets differ. have added file size thumbnail size. nearer size of uploading file size remaining bytes taken other params. have solved it.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -