嗨,我正在使用Flutter Camera插件,并且工作正常,主要问题是我无法找到一种方法来拍照时告诉插件图像文件名,在使用Kotlin的android系统中,这类似于:
photoUri = FileProvider.getUriForFile(requireActivity(), "io.awesomedomain", photoFile) // build uri on the app storage space and specific file name -> photoFile.
captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri) // define the pic name before picture is actually taken by the camera.
startActivityForResult(captureImageIntent, REQUEST_PHOTO) // start the camera
目前,我只是在从抖动相机插件返回图片XFile后重命名图片文件名,但这并不理想,因此我想知道是否丢失了某些东西。可以在颤振相机插件中预先指定文件名吗?
我目前正在使用最新的可用版本: camera: ^0.7.0+2
好的,看来我对Camera插件有误解,我注意到返回的XFile将图片放置在缓存目录中,并且实际上提供了一种将图片保存到更明确的存储的方法,xfile.saveTo
所以我这样做了:
var appDir = appDocDirectory.parent.path; // get app directory
file.saveTo('$appDir${Platform.pathSeparator}files${Platform.pathSeparator}${weightPicture.pictureFileName}');
因此,图片已正确保存在$ myAppDir / files / picName.jpg下,其中文件是我配置为有权写入的目录,而picName由应用程序根据需要定义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句