上传前如何检查视频文件的大小 [英] how do I check the file size of a video in flutter before uploading
本文介绍了上传前如何检查视频文件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将视频文件上传到云存储中,但是我想在上传之前检查视频文件的大小。如何实现此目的
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
推荐答案
如果您拥有文件的路径,则可以使用 dart:io
If you have the path of the file, you can use dart:io
var file = File('the_path_to_the_video.mp4');
您都可以使用:
print(file.lengthSync());
或
print (await file.length());
注意:返回的大小以<$ c为单位$ c>字节。
这篇关于上传前如何检查视频文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文