create method

  1. @override
Future<Map<String, Object?>> create({
  1. required Stream<List<int>> image,
  2. required PhotoCreateMeta meta,
  3. String? authorization,
  4. String? contentType,
})
override

Implementation

@override
Future<Map<String, Object?>> create({
  required Stream<List<int>> image,
  required PhotoCreateMeta meta,
  String? authorization,
  String? contentType,
}) async {
  final response = await _client.request(
    method: 'POST',
    path: '/img',
    headers: {'authorization': authorization, 'content-type': contentType},
    query: {'meta': meta},
    body: image,
  );

  final _body = await response.transform(utf8.decoder).join();

  if (jsonDecode(_body) case {'data': final Map data}) {
    return data.map((key, value) => MapEntry((key as String), value));
  }

  throw Exception('Invalid response');
}