how do I check the file size of a video in flutter before uploading

后端 未结 1 1564
清酒与你
清酒与你 2020-12-31 01:55

I want to upload a video file to my cloud storage but I want to check the size of the video file before I upload. how to achieve this

相关标签:
1条回答
  • 2020-12-31 02:25

    If you have the path of the file, you can use dart:io

    var file = File('the_path_to_the_video.mp4');
    

    You an either use:

    print(file.lengthSync()); 
    

    or

    print (await file.length());
    

    Note: The size returned is in bytes.

    0 讨论(0)
提交回复
热议问题