Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_storage] Add web support #45294

Closed
harryterkelsen opened this issue Nov 20, 2019 · 13 comments
Closed

[firebase_storage] Add web support #45294

harryterkelsen opened this issue Nov 20, 2019 · 13 comments
Assignees
Labels
c: new feature Nothing broken; request for a new capability p: firebase_storage The Firebase Storage plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-web Web applications specifically

Comments

@harryterkelsen
Copy link
Contributor

We should support firebase_storage on the web

@harryterkelsen harryterkelsen added c: new feature Nothing broken; request for a new capability plugin platform-web Web applications specifically p: firebase_storage The Firebase Storage plugin labels Nov 20, 2019
@yjbanov yjbanov added this to the Near-term Goals milestone Dec 12, 2019
@nilsreichardt
Copy link
Contributor

firebase_storage for web would be awesome! 😍

@parnurzeal
Copy link

+1!

@adamsowinski
Copy link

When will it be started? It is a showstopper for me :-(

@cbenhagen
Copy link
Contributor

Related to firebase/flutterfire#1972

@kaumudpa
Copy link

+1

@sbeitzel
Copy link

I just ran into this on a personal project, where I'm using universal_io to sidestep the lack of dart:io in flutter web context. However, the interface for firebase_storage specifies File from dart:io, which means its files are incompatible with the universal_io files the rest of my app traffics in. It would seem that in order to get this plugin to work for the web, it would require a breaking interface change. Either this plugin would have to stop using File and instead use some kind of stream, or it would have to introduce a new dependency on (for example, universal_io) a plugin that provides File implementations for all platforms.

Anyone got strong opinions? (He asked, on the Internet...)

@jans-y
Copy link

jans-y commented May 1, 2020

I will share my implementation, it's a little bit lame but it works.

pubspec.yaml

dependencies:
  firebase_storage:
  firebase:

upload_firebase_storage.dart

import 'dart:async';
import 'dart:typed_data';

import 'package:flutter/foundation.dart';

import './fake_native_firebase.dart' if (dart.library.io) 'package:firebase_storage/firebase_storage.dart' as fs;
import './fake_web_firebase.dart' if (dart.library.html) 'package:firebase/firebase.dart' as fb;

Future uploadFirebaseStorage(String path, Uint8List data, String contentType) async {
  try {
    if (kIsWeb) {
      fb.UploadTask uploadTask = fb.storage().ref(path).put(
            data,
            fb.UploadMetadata(
              contentType: contentType,
            ),
          );
      await uploadTask.future;
    } else {
      final fs.StorageReference storageReference = fs.FirebaseStorage().ref().child(path);

      final fs.StorageUploadTask uploadTask =
          storageReference.putData(data, fs.StorageMetadata(contentType: contentType));

      await uploadTask.onComplete;
    }
  } catch (error) {
    print("uploadFirebaseStorage: " + error);
    throw Exception(error);
  }
}

fake_native_firebase.dart

import 'dart:typed_data';

class StorageReference {
  StorageUploadTask putData(Uint8List data, storageMetadata) {}
}

class StorageMetadata {
  String contentType;

  StorageMetadata({this.contentType});
}

class FirebaseStorage {
  FirebaseStorage();
  ref() {}
}

class StorageUploadTask {
  var events;
  var onComplete;
}

class StorageTaskEvent {}

fake_web_firebase.dart

var storage;

class UploadTask {
  var future;
}

class UploadMetadata {
  String contentType;

  UploadMetadata({this.contentType});
}

@kf6gpe kf6gpe added the P1 High-priority issues at the top of the work list label May 29, 2020
@kf6gpe kf6gpe modified the milestone: Near-term Goals Jun 1, 2020
@yjbanov yjbanov added P2 Important issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Jun 16, 2020
@atreeon
Copy link

atreeon commented Jun 24, 2020

Hi, any ideas when you might start to work on this? A month, before the end of the year, next year?

@kf6gpe kf6gpe modified the milestone: [DEPRECATED] Near-term Goals Jul 7, 2020
@kf6gpe kf6gpe removed this from the [DEPRECATED] Near-term Goals milestone Jul 22, 2020
@cyanglaz
Copy link
Contributor

@kroikie Should we move this to the flutterfire repo?

@Hixie Hixie removed this from the None milestone Aug 17, 2020
@ditman ditman self-assigned this Oct 20, 2020
@ditman ditman added this to the 1.25 - November 2020 milestone Oct 20, 2020
@ditman
Copy link
Member

ditman commented Oct 23, 2020

I've been working on this for the last few weeks; it should be fully functional now. Here's the PR:

firebase/flutterfire#3917

You should be able to use this by specifying a git dependency to my branch for firebase_storage_web on your pubspecs.

@pcsosinski
Copy link

pcsosinski commented Jan 13, 2021

@ditman is there work left to do here? can you update the milestone if so?

@ditman
Copy link
Member

ditman commented Jan 14, 2021

Thanks for bringing this up @pcsosinski; This is done, but I must have misconfigured the PRs so it didn't get automatically closed. I'm closing the issue.

@ditman ditman closed this as completed Jan 14, 2021
@ditman ditman removed this from the November Beta Release (1.25) milestone Jan 14, 2021
@github-actions
Copy link

github-actions bot commented Aug 7, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: new feature Nothing broken; request for a new capability p: firebase_storage The Firebase Storage plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-web Web applications specifically
Projects
None yet
Development

No branches or pull requests