Changed api for getting assets to return and request correct type
This commit is contained in:
parent
1160306117
commit
72e0682c38
2 changed files with 20 additions and 6 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
|
@ -391,9 +392,9 @@ class DefaultApi {
|
||||||
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
|
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
|
||||||
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
|
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
|
||||||
///
|
///
|
||||||
/// Returns a [Future] containing a [Response] with a [JsonObject] as data
|
/// Returns a [Future] containing a [Response] with a [Uint8List] as data
|
||||||
/// Throws [DioError] if API call or serialization fails
|
/// Throws [DioError] if API call or serialization fails
|
||||||
Future<Response<dynamic>> getAsset({
|
Future<Response<Uint8List>> getAsset({
|
||||||
required String fid,
|
required String fid,
|
||||||
CancelToken? cancelToken,
|
CancelToken? cancelToken,
|
||||||
ValidateStatus? validateStatus,
|
ValidateStatus? validateStatus,
|
||||||
|
|
@ -404,9 +405,10 @@ class DefaultApi {
|
||||||
final _options = Options(
|
final _options = Options(
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
validateStatus: validateStatus,
|
validateStatus: validateStatus,
|
||||||
|
responseType: ResponseType.bytes,
|
||||||
);
|
);
|
||||||
|
|
||||||
final _response = await _dio.request<dynamic>(
|
final _response = await _dio.request<List<int>>(
|
||||||
_path,
|
_path,
|
||||||
options: _options,
|
options: _options,
|
||||||
cancelToken: cancelToken,
|
cancelToken: cancelToken,
|
||||||
|
|
@ -414,8 +416,20 @@ class DefaultApi {
|
||||||
onReceiveProgress: onReceiveProgress,
|
onReceiveProgress: onReceiveProgress,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Response<dynamic>(
|
final respData = _response.data;
|
||||||
data: _response,
|
if (respData == null) {
|
||||||
|
throw DioError(
|
||||||
|
requestOptions: _options.compose(
|
||||||
|
_dio.options,
|
||||||
|
_path,
|
||||||
|
),
|
||||||
|
type: DioErrorType.unknown,
|
||||||
|
error: 'Response was null',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response<Uint8List>(
|
||||||
|
data: Uint8List.fromList(respData),
|
||||||
headers: _response.headers,
|
headers: _response.headers,
|
||||||
isRedirect: _response.isRedirect,
|
isRedirect: _response.isRedirect,
|
||||||
requestOptions: _response.requestOptions,
|
requestOptions: _response.requestOptions,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name: tuuli_api
|
name: tuuli_api
|
||||||
version: 1.0.1
|
version: 1.0.2
|
||||||
description: OpenAPI API client
|
description: OpenAPI API client
|
||||||
homepage: homepage
|
homepage: homepage
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue