Skip to content

Commit ef9ea5e

Browse files
committed
update inputfile for dart and flutter
1 parent 731f039 commit ef9ea5e

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

templates/dart/lib/src/input_file.dart.twig

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,35 @@ class InputFile {
66
final String? filename;
77
final String? contentType;
88

9-
/// Provide a file, use `path` for IO platforms
10-
/// and provide `bytes` for web platform
11-
InputFile({this.path, this.filename, this.contentType, this.bytes}) {
9+
InputFile._({this.path, this.filename, this.contentType, this.bytes}) {
1210
if (path == null && bytes == null) {
13-
throw {{ spec.title | caseUcfirst }}Exception('One of `path` or `bytes` is required');
11+
throw AppwriteException('One of `path` or `bytes` is required');
1412
}
1513
}
14+
15+
/// Provide a file using `path`
16+
factory InputFile.fromPath({
17+
required String path,
18+
String? filename,
19+
String? contentType,
20+
}) {
21+
return InputFile._(
22+
path: path,
23+
filename: filename,
24+
contentType: contentType,
25+
);
26+
}
27+
28+
/// Provide a file using `bytes`
29+
factory InputFile.fromBytes({
30+
required List<int> bytes,
31+
required String filename,
32+
String? contentType,
33+
}) {
34+
return InputFile._(
35+
bytes: bytes,
36+
filename: filename,
37+
contentType: contentType,
38+
);
39+
}
1640
}

0 commit comments

Comments
 (0)