directus-dart
directus-dart copied to clipboard
Improve `DirectusFile.downloadUrl` method
https://github.com/apstanisic/directus-dart/blob/ec87f59f5260470a06f9672dddc1baf962a8b85d/lib/src/modules/files/directus_file.dart#L18
File download URL should return the whole download URL along with concatenated auth token of the current user
Something like this
String? downloadUrl(String baseUrl) {
if (id == null) return null;
// Remove trailing / if exists.
if (baseUrl.endsWith('/')) {
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
}
return '$baseUrl/assets/$id?access_token=${sdk.auth.tokens?.accessToken}';
}
That's a cool idea.
But we don't have access to SDK in DirectusFile
. User would either have to pass sdk or access token as a named param.
Something like: downloadUrl(String baseUrl, {String? accessToken})
, or downloadUrl(String baseUrl, {Directus? sdk})
.