imageToStorage function

String? imageToStorage(
  1. String sourcePath
)

将文件拷贝到Storage ID

sourcePath 源文件路径 返回 String 存储ID,如果文件不存在则返回null

Implementation

String? imageToStorage(String sourcePath) {
  String uuid = Uuid().v4();
  String destFile = FilePath.imagePath + uuid;
  File file = File(sourcePath);
  if (file.existsSync()) {
    file.copySync(destFile);
    return uuid;
  } else {
    return null;
  }
}