fun saveToolToFile(privateTool: PrivateTool) {
val newCoverPath = compressAndSaveImage(
AppApplication.context, privateTool.coverPath.toUri(), newFileName = "draft.jpg"
).toString()
val newPrivateTool = privateTool.copy(
coverPath = newCoverPath
)
val fileOutputStream =
FileOutputStream(AppApplication.context.filesDir.path + "/" + "creationDraft")
val objectOutputStream = ObjectOutputStream(fileOutputStream)
objectOutputStream.writeObject(newPrivateTool)
objectOutputStream.close()
fileOutputStream.close()
}
newFileName原来我用的是privateTool.name没考虑到用户可能没输入工具名就保存草稿的可能,所以导致找到了目录而不是文件,加了默认名就可以了