publicUrl method
Generate a public URL if the provider supports it.
Returns null when public URLs are not available.
Implementation
@override
Uri? publicUrl(String path) {
final key = _fullKey(path);
if (baseUrl != null) {
final base = baseUrl.toString().replaceAll(RegExp(r'/+$'), '');
final suffix = key.isEmpty ? '' : '/$key';
return Uri.parse('$base$suffix');
}
final scheme = client.useSSL ? 'https' : 'http';
final endpoint = client.endPoint;
final port = client.port;
final authorityPort = (port != 80 && port != 443) ? ':$port' : '';
final host = enforcePathStyle ? endpoint : '$bucket.$endpoint';
final pathSegment = enforcePathStyle ? '/$bucket/$key' : '/$key';
return Uri.parse('$scheme://$host$authorityPort$pathSegment');
}