Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data units in all related responses are now shifted to Bytes. #1

Open
instanceofMA opened this issue Mar 28, 2020 · 0 comments
Open
Assignees

Comments

@instanceofMA
Copy link

Data units in responses of routes like listAllFiles, listAllCollections are now shifted to 'Bytes'. In their responses, keys like totalSize will now be a NUMBER (1024), instead of STRING (1024 Bytes OR 1 KB) which it was previously.
For doing its formatting on the front end, you can define this function in the SDK:

pretty(number) {
   // Converts a number to proper data size units
   const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
   if (number === 0) {
       return '0 Bytes';
   }
   else {
       const i = Math.floor(Math.log(number) / Math.log(1024));
       return parseFloat((number / Math.pow(1024, i)).toFixed(2)) + ' ' + sizes[i];
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants