相关疑难解决方法(0)

格式化文件大小为MB,GB等

我需要使用合理的单位将文件大小显示为String.

例如

1L ==> "1 B";
1024L ==> "1 KB";
2537253L ==> "2.3 MB"
Run Code Online (Sandbox Code Playgroud)

等等

我找到了之前的答案,我觉得并不令人满意

我提出了自己的解决方案,它有类似的缺点:

private static final long K = 1024;
private static final long M = K * K;
private static final long G = M * K;
private static final long T = G * K;

public static String convertToStringRepresentation(final long value){
    final long[] dividers = new long[] { T, G, M, K, 1 };
    final String[] units = new String[] …
Run Code Online (Sandbox Code Playgroud)

java string format numbers

120
推荐指数
3
解决办法
9万
查看次数

ng2-file-upload:文件 maxFileSize 在 Angular 2 中使用打字稿限制为小于 1MB

这是我的代码。我无法上传大小超过 1 mb 的任何文件,但我已将 maxFileSize 设置为 50mb,请帮忙,我做错了什么?

@Component({
    moduleId: module.id,
    //define the element to be selected from the html structure.
    selector: 'NeedAnalysisConsult',
    //location of our template rather than writing inline templates.
    templateUrl: 'need-analysis-consultation.component.html',

})
export class NeedAnalysisConsultationComponent implements OnInit {
    model:any={};
    consultationDate: Date;
    organisation: string;
    devCode:String;
    maxFileSize = 50 * 1024 * 1024;


     //declare a property called fileuploader and assign it to an instance of a new fileUploader.
    //pass in the Url to be uploaded to, and pass the itemAlais, …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-template ng2-file-upload

0
推荐指数
1
解决办法
5820
查看次数