deleteIndividualPlaceFile function

Future<bool> deleteIndividualPlaceFile(
  1. String placeId
)

Delete an individual place file.

Implementation

Future<bool> deleteIndividualPlaceFile(String placeId) async {
  try {
    final fp = await getIndividualPlaceFilePath(placeId);
    final url = await getFileUrl(fp);
    final (:accessToken, :dPopToken) = await getTokensForResource(
      url,
      'DELETE',
    );
    final r = await http.delete(
      Uri.parse(url),
      headers: {
        'Accept': '*/*',
        'Authorization': 'DPoP $accessToken',
        'Connection': 'keep-alive',
        'DPoP': dPopToken,
      },
    );

    // 404 means file doesn't exist, which is fine.
    return r.statusCode >= 200 && r.statusCode < 300 || r.statusCode == 404;
  } catch (_) {
    return false;
  }
}