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

File Upload Explorer showing GB instead of MB #1761

Closed
sbastias opened this issue Aug 16, 2018 · 4 comments · Fixed by #1776
Closed

File Upload Explorer showing GB instead of MB #1761

sbastias opened this issue Aug 16, 2018 · 4 comments · Fixed by #1776
Assignees
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@sbastias
Copy link

Informations

  • Node.js version: 10.6.0
  • npm version: 6.1.0
  • Strapi version: 3.0.0-alpha.13
  • Database: MongoDB
  • Operating system: Ubuntu 14.04

What is the current behavior?
The file upload system is indicating GB instead of MB.
image

Steps to reproduce the problem
Upload a large file (video?), navigate to "Files Upload"

What is the expected behavior?
Should be MB, not GB

Suggested solutions
Not sure!

@danielehrhardt
Copy link

Can confirm this

@lauriejim lauriejim added issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve status: confirmed Confirmed by a Strapi Team member or multiple community members good first issue Good for newcomers labels Aug 20, 2018
@lauriejim
Copy link
Contributor

Hello @sbastias and @danielehrhardt , thank you for reporting this issue. We are currently on another feature and bug fix. Since time is lacking on our side, feel free investigate and submit a PR, we’ll appreciate your contribution on this issue!

Check out the contributing guide to get started: https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md

@sbastias
Copy link
Author

I can't do a PR because I didn't fork the repo, I cloned it to make a bunch of other customizations.

It's a simple fix though! I just tested it on KB MB and GB files:

image

It's this function getUnit in:
strapi/packages/strapi-plugin-upload/admin/src/components/Li/index.js

Currently:

getUnit = (value) => {
    let unit;
    let divider;
    
    switch (true) {
      case value > 10000:
        unit = 'GB';
        divider = 1000;
        break;
      case value < 1:
        unit = 'B';
        divider = 1;
        break;
      case value > 1000:
        unit = 'MB';
        divider = 1000;
        break;
      default:
        unit = 'KB';
        divider = 1;
    }

    return { divider, unit };
  }

Should be:

getUnit = (value) => {
    let unit;
    let divider;
    
    switch (true) {
      case value > 1000000:
        unit = 'GB';
        divider = 1000000;
        break;
      case value < 1:
        unit = 'B';
        divider = .001;
        break;
      case value > 1000:
        unit = 'MB';
        divider = 1000;
        break;
      default:
        unit = 'KB';
        divider = 1;
    }

    return { divider, unit };
  }

danielehrhardt pushed a commit to danielehrhardt/strapi that referenced this issue Aug 20, 2018
@danielehrhardt
Copy link

Thank you @sbastias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants