// Automatic FlutterFlow imports import '/backend/schema/structs/index.dart'; import '/backend/schema/enums/enums.dart'; import '/actions/actions.dart' as action_blocks; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'index.dart'; // Imports other custom actions import '/flutter_flow/custom_functions.dart'; // Imports custom functions import 'package:flutter/material.dart'; // Begin custom action code // DO NOT REMOVE OR MODIFY THE CODE ABOVE! import 'dart:convert'; // Import for base64 decoding import 'dart:io'; // Import for file operations import 'package:path_provider/path_provider.dart'; // Import for temporary directory Future convertToUploadFile(String img) async { // Decode the base64 string into bytes Uint8List bytes = base64.decode(img); // Create a temporary file to store the image final tempDir = await getTemporaryDirectory(); final tempPath = tempDir.path; final tempFile = await File('$tempPath/image.jpg').create(); await tempFile.writeAsBytes(bytes); // Create an FFUploadedFile object using the temporary file return FFUploadedFile( bytes: bytes, name: 'image.jpg', ); }