Skip to content

Commit

Permalink
[MNT-24127] Added rest endpoint implementation to calculating folder …
Browse files Browse the repository at this point in the history
…size
  • Loading branch information
mohit-singh4 committed Mar 12, 2024
1 parent 473e368 commit 2d8231e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.Serializable;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.text.DecimalFormat;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -3568,9 +3569,10 @@ public Map<String, Object> getFolderSize(String folderNodeId){
String[] sizes = {"Bytes", "KB", "MB", "GB", "TB", "PB"};
int i = (int) Math.floor(Math.log(size) / Math.log(k));
float finalSize = Float.parseFloat(String.valueOf(size / Math.pow(k, i)));
DecimalFormat form = new DecimalFormat("0.00");
Map<String, Object> response = new HashMap<>();
response.put("id", folderNodeId);
response.put("size", String.valueOf(finalSize + " " + sizes[i]));
response.put("size", String.valueOf(form.format(finalSize) + " " + sizes[i]));
return response;
}

Expand Down

0 comments on commit 2d8231e

Please sign in to comment.