8000 [firebase_storage] writeToFile not correctly invoking exception · Issue #1418 · firebase/flutterfire · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[firebase_storage] writeToFile not correctly invoking exception #1418
Closed
@MichaelM97

Description

@MichaelM97

When downloading a file from firebase storage, if the file does not exist then when writeToFile() is called then the catch in the below example is not invoked.

However, the catch is correctly invoked when calling other functions, like getMetadata().

Code for writeToFile():

    final directory = await getApplicationDocumentsDirectory();
    final File file = File(directory.path);
    final StorageReference ref = _firebaseStorage.ref().child("Does_not_exist");

    try {
      final StorageFileDownloadTask downloadTask = ref.writeToFile(file);
      await downloadTask.future;
    } catch (error) {
      print("Error! - " + error.toString());
    }

Exception that is apparently 'Unhandled':

23:02:59.472 3 info flutter.tools [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(Error -13021, FIRStorageErrorDomain, User does not have permission to access gs://test-app.appspot.com/Does_not_exist.)
23:02:59.472 4 info flutter.tools #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
23:02:59.472 5 info flutter.tools #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
23:02:59.472 6 info flutter.tools <asynchronous suspension>
23:02:59.472 7 info flutter.tools #2      StorageFileDownloadTask._start (package:firebase_storage/src/firebase_storage.dart:137:62)
23:02:59.472 8 info flutter.tools <asynchronous suspension>
23:02:59.472 9 info flutter.tools #3      StorageReference.writeToFile (package:firebase_storage/src/storage_reference.dart:134:10)

Code for getMetaData():

    final StorageReference ref = _firebaseStorage.ref().child("Does_not_exist");

    try {
      await ref.getMetadata();
    } catch (error) {
      print("Error! - " + error.toString());
    }

Exception that is correctly handled:

23:07:55.205 13 info flutter.tools  Error! - PlatformException(Error -13021, FIRStorageErrorDomain, User does not have permission to access gs://test-app.appspot.com/Does_not_exist.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked: customer-responseWaiting for customer response, e.g. more information was requested.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0