mardi 29 décembre 2015

how to convert bytes into mbs,gbs

I am trying to convert number of bytes into kilobytes,megabytes.i have generated a table in which all files are getting with name and filesize.but the filesize is in bytes, I just want to convert long length of numbers into mbs,gbs. this is show file's code:

  for file in files[1]
            if file[1][:size] == nil
                filesize = 0
            else
                filesize = file[1][:size]
            end
            data += [["#{file[1][:name]}", "#{filesize.to_s(:human_size)} Bytes"]]
        end

In which i have used .to_s(:humansize) function due to which this error is encountered

    can't convert Symbol into Integer 

thanks!

Aucun commentaire:

Enregistrer un commentaire