delete method

Future<int> delete()

Deletes the file at this FileStorageReference.

Implementation

Future<int> delete() async {
  assert(id > 0);
  final String url = "$fileEndpointUri/$id";

  http.Response response =
      await httpr.delete(Uri.encodeFull(url), headers: headers);
  int httpStatusCode = response.statusCode;

  switch (httpStatusCode) {
    case 200:
    case 204:
      {
        return httpStatusCode;
      }
    default:
      // All other cases are treated as an error.
      {
        Map<String, dynamic> responseJson =
            json.decode(response.body) as Map<String, dynamic>;
        throw CarpServiceException(
          httpStatus: HTTPStatus(httpStatusCode, response.reasonPhrase),
          message: responseJson["message"].toString(),
          path: responseJson["path"].toString(),
        );
      }
  }
}