createBucket method

Future<Response> createBucket({
  1. required String bucketName,
  2. bool isPrivate = false,
})

Implementation

Future<Response> createBucket({
  required String bucketName,
  bool isPrivate = false,
}) async {
  FormData formData = FormData();
  formData.fields.add(MapEntry('bucket', bucketName));
  formData.fields.add(MapEntry('isPrivate', isPrivate ? 'YES' : 'NO'));
  formData.fields.add(MapEntry('region', regionModel.regionKey));

  Response response;

  var url = 'https://${regionModel.regionUrl}/bucket/create';

  try {
    response = await _dio.post(
      url,
      data: formData,
      options: Options(headers: header),
    );
    return response;
  } on DioError catch (error) {
    throw Exception(error.message);
  }
}