Skip to content

Commit

Permalink
fix: create sub for File
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Oct 5, 2023
1 parent 86e4c04 commit d96e2eb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/storage_client/lib/src/fetch.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io' show File;
import 'dart:typed_data';

import 'package:http/http.dart' as http;
Expand All @@ -10,6 +9,8 @@ import 'package:mime/mime.dart';
import 'package:retry/retry.dart';
import 'package:storage_client/src/types.dart';

import 'file_io.dart' if (dart.library.js) './file_stub.dart';

Fetch storageFetch = Fetch();

class Fetch {
Expand Down
1 change: 1 addition & 0 deletions packages/storage_client/lib/src/file_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'dart:io' show File;
8 changes: 8 additions & 0 deletions packages/storage_client/lib/src/file_stub.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'dart:typed_data';

/// A stub for the `dart:io` [File] class. Only the methods used by the storage client are stubbed.
class File {
String get path => throw UnimplementedError();

Uint8List readAsBytesSync() => throw UnimplementedError();
}
3 changes: 2 additions & 1 deletion packages/storage_client/lib/src/storage_file_api.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:io' show File;
import 'dart:typed_data';

import 'package:storage_client/src/fetch.dart';
import 'package:storage_client/src/types.dart';

import 'file_io.dart' if (dart.library.js) './file_stub.dart';

class StorageFileApi {
final String url;
final Map<String, String> headers;
Expand Down

0 comments on commit d96e2eb

Please sign in to comment.