getSecureStorageToken method

Future<AttachmentCredentialsModel> getSecureStorageToken({
  1. required String tenantId,
  2. required String storageId,
  3. required String fileName,
})

Implementation

Future<AttachmentCredentialsModel> getSecureStorageToken({
  required String tenantId,
  required String storageId,
  required String fileName,
}) async {
  try {
    String url =
        '${constants.API_HOST}/api/tenant/$tenantId/file/credentials?filename=$fileName&storageId=$storageId';
    var response = await http.get(Uri.parse(url), headers: {
      "Authorization": token,
    });
    if (response.statusCode == 200) {
      final jsonResponse = jsonDecode(response.body);
      AttachmentCredentialsModel creds =
          AttachmentCredentialsModel.fromJson(jsonResponse);
      return creds;
    } else {
      throw Exception(response.reasonPhrase);
    }
  } catch (e) {
    throw Exception(e.toString());
  }
}