[FFUploadedFile] Get info from current active file from another action

Troubleshooting
Resolved

Hi,

i have an action that is currently activ in my workflow.

This actions output is:

return FFUploadedFile(name: fileName, bytes: bytes);

Now i need this info or the file again to create a filepath to store the image on the mobile users device, so i did this as example:

Future saveImage(FFUploadedFile imageToSave) async {
  // my code is here
}

and as well defined the argument

So far so good.

Now what i want to do is from my other action following information: fileName (which is the file type actually) and the original bytes.

FFUploadedFile(name: fileName, bytes: bytes);

Sorry a bit new to FF, but do i have to save these information with my previous action in app states to reuse it or i can just load the file and retrieve the infos?

Also another part i have two lines in the code where the editor is telling me i should make one of these nullable, but for me it sounds somehow wrong.

So the editor is telling me i have to make "Directory" nullable or filePath.

Directory? filePath = await getExternalStorageDirectory();
String imagePath = '${filePath}/${imageToSave.fileName}';

But they should not be nullable in my opinion, or do i miss something?

The code:

Future saveImage(FFUploadedFile imageToSave) async {
  bool permissionGranted = await Permission.storage.request().isGranted;
  if (!permissionGranted) {
    throw Exception('Permission granted');
  }

  Directory? filePath = await getExternalStorageDirectory();
  String imagePath = '${filePath}/${imageToSave.fileName}';

  try {
    await Dio().download(imageToSave, imagePath);
  } catch (e) {
    throw Exception('Failed to download');
  }
}

Anyway thanks for any help

What have you tried so far?

Several times following the editors recommendation and google

Did you check FlutterFlow's Documentation for this topic?
No
2
1 reply