title: Record Audio and upload file to firebase storage Flutter Web
body: <p>I am using the <a href="https://pub.dev/packages/flutter_sound" rel="nofollow noreferrer">flutter_sound</a> package to record and play audio. On Flutter Web, on stopping the recording the recorder returns a path/URL of this type: <code>blob:http://localhost:63986/b60f31ce-b94d-48c8-8a4a-2d939effe6d8</code></p>
  <p>I want to upload the audio recording to Firebase Storage but dart.io can't be used for flutter-web so can't use the File method. Even after searching, I didn't find a way to achieve it. I don't know how to proceed. How can I write the audio to file and upload it to firebase?</p>
  <p>My Code:</p>
  <pre><code>  import 'dart:html' as html;
    import 'dart:io' as io;
  
    final recorder = FlutterSoundRecorder();
    final player = FlutterSoundPlayer();
    String fileName;
  
    @override
    void initState() {
      super.initState();
      initRecorder();
    }
  
    @override
    void dispose() {
      recorder.closeRecorder();
      player.closePlayer();
      super.dispose();
    }
  
    Future&lt;void&gt; initRecorder() async {
      if (!kIsWeb) {
        final status = await Permission.microphone.request();
        if (status != PermissionStatus.granted) {
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(content: Text('Grant Permission form mic first!')),
          );
        }
      }
      await recorder.openRecorder();
      await player.openPlayer();
      recorder.setSubscriptionDuration(Duration(milliseconds: 500));
    }
  
    Future&lt;void&gt; record() async {
      fileName = DateTime.now().toString();
      await recorder.startRecorder(toFile: fileName);
    }
  
    Future&lt;void&gt; stop() async {
      path = await recorder.stopRecorder();
      if (kIsWeb) {
        if (path == null) {
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(content: Text('Grant Permission for mic first!')),
          );
        } else {
          // Get File from path and upload it to Firebase
  
          print(path);
          // not working for Web
          // final audioFile = io.File(path);
  
          // html.File() doesn't take path/Url as parameter but
          // File(List&lt;Object&gt; fileBits, String fileName,[Map? options])
  
          /*
          await FirebaseStorage.instance
              .ref()
              .child('users/uploads/$fileName.mp3')
              .putData(file!.bytes!);*/
        }
      } else if (!kIsWeb) {
        if (path == null) {
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(content: Text('Grant Permission for mic first!')),
          );
        } else {
          //final audioFile = io.File(path);
          // await FirebaseStorage.instance
          //     .ref()
          //     .child('users/uploads/$fileName.mp3')
          //     .putFile(audioFile);
        }
      }
    }
  </code></pre>