How to use filesize - 10 common examples

To help you get started, we’ve selected a few filesize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github collectiveaccess / providence / js / mediauploader.js View on Github external
constructor(props) {
        super(props);

        this.statusMessages = {
            idle: 'Select files to upload',
            ready: 'Ready to upload',
            start: 'Starting upload',
            upload: 'Uploading files',
            complete: 'Upload complete',
            error: 'Error'
        };
        
        this.errorMessages = {
        	userquota: 'User storage allocation exceeded',
            sessionfilelimit: 'Limit of ' + this.props.maxFilesPerSession + ' files per upload exceeded',
            filesizelimit: fileSize(maxFileSize, {round: 1, base: 10}) + ' file size limit exceeded',
            systemquota: 'System storage allocation exceeded'
        };

        this.state = {
            filesSelected: 0,
            filesUploaded: 0,
            status: this.statusMessages['idle'],	/* Current status code; determined status message to be displayed */
            queue: [],					/* List of pending uploads */
            connections: {},			/* List of open tus upload connections */
            connectionIndex: 0,			/* Index/key for next connection; changes for each allocated connection */	
            error: null,				/* Current symbolic error code (Ex. 'userquota', 'filesizelimit') */
            errorMessage: null,			/* Current error message for display */
            errorType: null,			/* Numeric error type; ERR_RECOVERABLE (1) = Resolvable by user; ERR_BLOCKING (2) = Fatal, don't allow upload */

            recentList: [],
github dreamnettech / dreamtime / src / electron / src / modules / tools / system.js View on Github external
if (!existsSync(dirpath)) {
      return false
    }

    // these files must exist
    const files = ['cm.lib', 'mm.lib', 'mn.lib']

    for (const file of files) {
      const filepath = getCheckpointsPath(file)

      if (!existsSync(filepath)) {
        return false
      }

      const stats = statSync(filepath)
      const size = filesize(stats.size, { exponent: 2, output: 'object' })

      if (size.value < 690) {
        return false
      }
    }

    return true
  }
github freenas / webui / src / app / pages / storage / volumes / manager / vdev / vdev.component.ts View on Github external
}
    }
    totalsize = smallestdisk * this.disks.length;
    if (this.type === "mirror") {
      estimate = smallestdisk; 
    } else if (this.type === "raidz") {
      estimate = totalsize - smallestdisk;
    } else if (this.type === "raidz2") {
      estimate = totalsize - 2 * smallestdisk;
    } else if (this.type === "raidz3") {
      estimate = totalsize - 3 * smallestdisk;
    } else {
      estimate = totalsize; // stripe
    }
        
    this.size = filesize(estimate, {standard : "iec"});
  }
github fazo96 / ipfs-drive / src / components / SingleFileManager.js View on Github external
function SingleFileManager({ item, ascend }) {
  const { name, size, hash } = item;
  return (
    }/>}
    />
    
      
        
        
          
        
        
          
        
      
    
  );
}
github brainhubeu / react-file-input / src / components / FileInfo / Metadata.js View on Github external
const Metadata = ({ extension, name, size, type }) => {
  const formattedSize = filesize(size, { separator: ',' });

  return (
    <div>
      <div>
        <span>{name}</span>{extension ? `.${extension}`: ''} ({formattedSize}) {type}
      </div>
    </div>
  );
};
github alibaba / ice / tools / iceworks / renderer / src / pages / Home / ProjectDashboard / Assets.jsx View on Github external
files.forEach((file) => {
      const fullPath = path.join(dirPath, file);
      stats = fs.lstatSync(fullPath);
      if (stats.isDirectory()) {
        list = list.concat(this.recursiveReaddirSync(fullPath, rootDir));
      } else {
        list.push({
          path: path.relative(rootDir, fullPath),
          size: filesize(stats.size),
          fullPath,
          statsSize: stats.size,
        });
      }
    });
    list = list.sort((a, b) => {
github airbnb / lunar / scripts / checks / compareBuildSizes.ts View on Github external
Object.entries(nextSizes).forEach(([pkgName, stats]) => {
    const prevEsm = getPrevSize(pkgName, 'esm');
    const prevLib = getPrevSize(pkgName, 'lib');
    const diff = calculateDiff(prevEsm, stats.esm);

    if (!isFinite(diff) || diff === 0 || diff === 0.0) {
      return;
    }

    const row = [
      pkgName,
      formatDiff(diff),
      size(stats.esm),
      prevEsm === 0 ? 'N/A' : size(prevEsm),
      size(stats.lib),
      prevLib === 0 ? 'N/A' : size(prevLib),
    ];

    rows.push(`| ${row.join(' | ')} |`);
  });
github wxajs / wxa / packages / wxa-plugin-dependencies-analysis / client / components / echarts / treemap.js View on Github external
formatter(info) {
                const value = info.value;
                const path = info.data.path;
                const treePathInfo = info.treePathInfo;
                const treePath = [];

                for (let i = 1; i &lt; treePathInfo.length; i++) {
                    treePath.push(treePathInfo[i].name);
                }

                return [
                    '<div class="tooltip-title">dep path: ' + formatUtil.encodeHTML(treePath.join('-&gt;')) + '</div>',
                    '<div class="tooltip-title">size: ' + filesize(value) + '</div>',
                    //'outputPath: ' + formatUtil.encodeHTML(path)
                ].join('');
            }
        },
github Feverqwe / tSearch / src / components / PipelineSelector.jsx View on Github external
}, Promise.resolve(node)).then((result) => {
      this.selectorStore.verifyType(result);
      if (this.state.previewMode) {
        switch (this.props.previewType) {
          case 'date': {
            result = new Date(result * 1000).toString();
            break;
          }
          case 'size': {
            try {
              result = filesize(result);
            } catch (err) {
              logger.warn('filesize error', result, err);
              result = 'n/a';
            }
            break;
          }
        }
      }
      return result;
    }).then(result => {
      if (this.output) {
github ipfs-shipyard / ipfs-share-files / src / components / file / File.js View on Github external
render () {
    const { name, type, shareHash, error, t } = this.props
    const size = filesize(this.props.size, { round: 0, spacer: '' })

    const fileNameClass = classnames({ 'charcoal': !error, 'gray': error }, ['ph2 f6 b truncate'])
    const fileSizeClass = classnames({ 'charcoal-muted': !error, 'gray': error }, ['f6'])

    return (
      <div>
        <a rel="noopener noreferrer" href="{`${ENDPOINTS.gateway}/${shareHash}/${encodeURI(name)}`}" style="{{" title="{t('box.viewOnGateway')}">
          
          <span>{name}</span>
          <span>{size &amp;&amp; `(~${size})`}</span></a></div>

filesize

JavaScript library to generate a human readable String describing the file size

BSD-3-Clause
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis

Popular filesize functions