带抖动的FirebaseStorage

问题描述 投票:0回答:1

我是Firebase的新手,我无法弄清楚我应该将什么样的参数传递给putfile中的以下代码,并且有关带抖动的Firebase是否有任何教程或适当的文档?

final FirebaseStorage _storage = FirebaseStorage(storageBucket:"https://console.firebase.google.com/project/blalala/storage/blBLlabla4ef54.appspot.com");
  StorageUploadTask _uploadTask;

  void firebasebackend(){
    String filePath = "images/ts2.jpg";
    setState(() {
      _uploadTask = _storage.ref().child(filePath).putFile("What shud i pass here?");
    });
  }
firebase flutter firebase-storage
1个回答
0
投票

根据firebase_storage插件的代码:

  /// Asynchronously uploads a file to the currently specified
  /// [StorageReference], with an optional [metadata].
  StorageUploadTask putFile(File file, [StorageMetadata metadata]) {
    assert(file.existsSync());
    final _StorageFileUploadTask task =
        _StorageFileUploadTask._(file, _firebaseStorage, this, metadata);
    task._start();
    return task;
  }

file作为参数,将类型为StorageMetadata的变量作为可选参数。

https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_storage/lib/src/storage_reference.dart#L61

https://api.dart.dev/stable/2.7.0/dart-io/File-class.html

© www.soinside.com 2019 - 2024. All rights reserved.