S3 Bucket to store Media Upload

Hi Everyone,

As you all know Firebase is expensive and slow. I'm using it right now with https://imagekit.io/ to save and display photos and videos in my app.

I tried today to switch to AWS using a S3 bucket, CloudFront as CDN and APi Gateway to upload files.

It's working well locally. so all my setup is ok.

I created an API call in FF to upload the file which is working but it send to my s3 bucket all the FFUploadedFile data, instead of just the photo or video. I was thinking that I need the path of it to send it.

So I wrote this function:

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/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 'package:path_provider/path_provider.dart';

Future<String?> getMediaLocalPath(FFUploadedFile file) async {
  // Add your function code here!
  try {
    // Get the temp folder
    final String tempDir = (await getTemporaryDirectory()).path;

    return '${tempDir}/${file.name}';
  } catch (e) {
    print(e);
    return null;
  }
}


But it's not working as I get this error:

MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)

My question is, is it possible to achieve what I want so I can spend more time fixing the issue. Or it is not possible and we don't have choice to use Firebase.

BTW, just developing the app coast me 49$ in one week using https://imagekit.io/ so I really need to find a solution as I can't go live like that.

Thank you all


3
2 replies