从Firebase存储下载时出错

时间:2018-07-15 13:58:27

标签: firebase flutter firebase-storage

我正在尝试下载我上传到Firebase的图像 我将下载网址作为httpPath传递。但是E/StorageException(16586): StorageException has occurred. E/StorageException(16586): Object does not exist at location. E/StorageException(16586): Code: -13010 HttpResult: 404 E/StorageException(16586): StorageException has occurred. E/StorageException(16586): Object does not exist at location.

Future<Null>downloadFile(String httpPath) async{
    final Directory appDir = await getApplicationDocumentsDirectory();
    final appDirPath = appDir.path;

    final RegExp regExp = RegExp('([^?/]*\.(jpg))');
    final filename = regExp.stringMatch(httpPath);
    final File thefile = File('${appDirPath}/$filename');

    final StorageReference sref = FirebaseStorage.instance.ref().child('storeFolderName').child(filename);
    final StorageFileDownloadTask fileDownloadTask = sref.writeToFile(thefile);
    final int byteNumber = (await fileDownloadTask.future).totalByteCount;
    print('your file byte number is : $byteNumber');
}

0 个答案:

没有答案