read method

Future read({
  1. required String dir,
})

Read a file in a given MFS. For more: https://docs.ipfs.io/reference/http/api/#api-v0-files-read

Implementation

Future<dynamic> read({required String dir}) async {
  _checkDir(dir);
  var params = {
    'arg': dir,
    'offset': 0,
    'count': 10000000,
  };
  try {
    var response = await _ipfsService.post(
        url: '$url/api/v0/files/read?',
        queryParameters: params,
        authorizationToken: authorizationToken,
        responseType: ResponseType.bytes);
    return response;
  } on DioError catch (e) {
    // The request was made and the server responded with a status code
    // that falls out of the range of 2xx and is also not 304.
    if (e.response != null) {
      return e.response?.data;
    }
  }
}