Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User lorezyra's Avatar
    Join Date
    Dec 2007
    Location
    Japan -- 日本
    Posts
    531
    Vote Rating
    3
    lorezyra will become famous soon enough

      0  

    Default Ext.utl.Format.fileSize() -- doesn't support GB and TB file sizes

    Ext.utl.Format.fileSize() -- doesn't support GB and TB file sizes


    fileSize() function will only calculate up to the megabyte range. This should be updated to handle much larger file sizes that will exist on a typical web-server.

    Original Source for EXTjs 3.3.1
    [http://dev.sencha.com/deploy/dev/doc...rmat-fileSize]

    PHP Code:

    /**
             * Simple format for a file size (xxx bytes, xxx KB, xxx MB)
             * @param {Number/String} size The numeric value to format
             * @return {String} The formatted file size
             */
            
    fileSize : function(size) {
                if (
    size 1024) {
                    return 
    size " bytes";
                } else if (
    size 1048576) {
                    return (
    Math.round(((size*10) / 1024))/10) + " KB";
                } else {
                    return (
    Math.round(((size*10) / 1048576))/10) + " MB";
                }
            }, 
    Below is my recommended patch for 3.x and 4.x

    PHP Code:



    /**
             * Simple format for a file size (xxx bytes, xxx KB, xxx MB and upto xxx PB)
             * @param {Number/String} size The numeric value to format
             * @return {String} The formatted file size
             */
            
    fileSize : function(size) {
            if (
    size 1024) { //pow(2,10)
                
    return size " bytes";
            } else if (
    size 1048576) { //pow(2,20)
                
    return (Math.round(((size*10) / 1024))/10) + " KB";
            } else if (
    size 1073741824) { //pow(2,30)
                
    return (Math.round(((size*10) / 1048576))/10) + " MB";
            } else if (
    size 1099511627776) { //pow(2,40)
                
    return (Math.round(((size*100) / 1073741824))/100) + " GB";
            } else if (
    size 1125899906842624) { //pow(2,50)
                
    return (Math.round(((size*100) / 1099511627776))/100) + " TB";
            } else { 
    //pow(2,60)
                
    return (Math.round(((size*100) / 1125899906842624))/100) + " PB";
            }
            }, 
    Perfection as a goal is a nice idea that can point one in a specific direction. However, since "perfection" is an ever changing (evolving?) and moving target, one must admit that perfection can never be obtained...

    When in doubt, check the d4mn source code!

  2. #2
    Sencha User lorezyra's Avatar
    Join Date
    Dec 2007
    Location
    Japan -- 日本
    Posts
    531
    Vote Rating
    3
    lorezyra will become famous soon enough

      0  

    Default Related post

    Related post


    I found this thread after I created my post. However, it's in the premium section...


    http://www.sencha.com/forum/showthre...o-calculate-GB
    Perfection as a goal is a nice idea that can point one in a specific direction. However, since "perfection" is an ever changing (evolving?) and moving target, one must admit that perfection can never be obtained...

    When in doubt, check the d4mn source code!

  3. #3
    Sencha User lorezyra's Avatar
    Join Date
    Dec 2007
    Location
    Japan -- 日本
    Posts
    531
    Vote Rating
    3
    lorezyra will become famous soon enough

      0  

    Default


    //bump++;
    Perfection as a goal is a nice idea that can point one in a specific direction. However, since "perfection" is an ever changing (evolving?) and moving target, one must admit that perfection can never be obtained...

    When in doubt, check the d4mn source code!

  4. #4
    Sencha User lorezyra's Avatar
    Join Date
    Dec 2007
    Location
    Japan -- 日本
    Posts
    531
    Vote Rating
    3
    lorezyra will become famous soon enough

      0  

    Lightbulb Adding Thresholds and decimal places

    Adding Thresholds and decimal places


    I considered the necessity to add thresholds to the filesize funtion. By default, the function below will return a string that is similar to the Windows style of filesizes. However, some cases exists where you want to keep the threshold at 100%, thereby only indicating that file by actual size...
    Additionally, I've added another optional parameter for decimal places. This makes it flexible to display more accurate filesizes upto 4 decimal places.


    For Example:

    Ext.util.format.fileSize('934123');
    //returns: "912.23 KB"

    Ext.util.format.fileSize('973265', 1,2);
    //returns: "950.45 KB"

    Ext.util.format.fileSize('973265', 1,1);
    //returns: "950.5 KB"

    Ext.util.format.fileSize('957523265', 0.85,3);
    //returns: "0.892 GB"

    Ext.util.format.fileSize('957523265', .98);
    //returns: "913.17 MB"


    PHP Code:



    /**
             * Simple format for a file size (xxx.x bytes, xxx.xx KB, xxx.xx MB and upto xxx PB)
             * @param {Number/String} size The numeric value to format
              * @param {Number/String} threshold (optional) The numeric value to force size to use the next larger filesize indicator
              * @param {Number/String} decimal (optional) The numeric value of decimal places to show in the returned string
             * @return {String} The formatted file size
             */
            
    fileSize : function(sizethresholddecimal) {
            
    thresholdthresholdthreshold0.95;//set default to a Windows style of FileSizes
            
    thresholdMath.min(Math.max(threshold0.75), 1); //should be between 75-100%
            
    decimaldecimaldecimal2;//set default to 2 decimal units
            
    decimalMath.min(Math.max(decimal0), 4); //should be between 0-4
            
    if (size 1024*threshold) { //pow(2,10)
                
    return size " bytes";
            } else if (
    size 1048576*threshold) { //pow(2,20)
                
    return (Math.round(((size*Math.pow(10,decimal)) / 1024))/Math.pow(10,decimal)) + " KB";
            } else if (
    size 1073741824*threshold) { //pow(2,30)
                
    return (Math.round(((size*Math.pow(10,decimal)) / 1048576))/Math.pow(10,decimal)) + " MB";
            } else if (
    size 1099511627776*threshold) { //pow(2,40)
                
    return (Math.round(((size*Math.pow(10,decimal)) / 1073741824))/Math.pow(10,decimal)) + " GB";
            } else if (
    size 1125899906842624*threshold) { //pow(2,50)
                
    return (Math.round(((size*Math.pow(10,decimal)) / 1099511627776))/Math.pow(10,decimal)) + " TB";
            } else { 
    //pow(2,60)
                
    return (Math.round(((size*Math.pow(10,decimal)) / 1125899906842624))/Math.pow(10,decimal)) + " PB";
            }
            }, 
    Perfection as a goal is a nice idea that can point one in a specific direction. However, since "perfection" is an ever changing (evolving?) and moving target, one must admit that perfection can never be obtained...

    When in doubt, check the d4mn source code!

  5. #5
    Sencha User
    Join Date
    May 2012
    Posts
    1
    Vote Rating
    0
    garnment is on a distinguished road

      0  

    Default Another function very simple

    Another function very simple


    For our french friends !!!

    PHP Code:
    formatSize: function(bytes){
         var 
    TabUnite = Array("octets""Ko""Mo""Go""To""Po""Eo""Zo""Yo");
         var 
    ;
         while(
    bytes >= 1024 && TabUnite.length-1){ 
         
    bytes bytes 1024;
         
    i++; 
         }
    bytes Math.round(bytes*100)/100;
    return 
    bytes+" "+TabUnite[i];


Similar Threads

  1. Ext.util.Format.fileSize is not localized
    By mhankus in forum Ext 3.x: Bugs
    Replies: 0
    Last Post: 22 Jan 2011, 11:21 AM
  2. ExtJS 2.1 file sizes?
    By RyanZec in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 21 Apr 2008, 4:29 AM
  3. Date modification: support for 'P' format
    By orgutus in forum Community Discussion
    Replies: 3
    Last Post: 4 Jan 2008, 8:30 AM
  4. File Sizes??
    By ReyBango in forum Community Discussion
    Replies: 2
    Last Post: 14 Jun 2007, 4:29 AM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar