apstanisic / directus-dart

Directus SDK for Dart and Flutter
MIT License
37 stars 23 forks source link

Add thumbnailUrl method to FilesHandler #55

Closed devmaslove closed 2 years ago

devmaslove commented 2 years ago

It was necessary to receive the thumbnail url without having to add parameters manually. Now:

final fileLink = file.downloadUrl(AppEnv.link) ?? '';
final imageThumb = '$fileLink?fit=cover&width=48&height=48&quality=50&format=jpg';

Need:

final imageThumb = file.thumbnailUrl(AppEnv.link, width: 48, height: 48, quality: 50, format: DirectusThumbnailFormat.jpg);
apstanisic commented 2 years ago

This is cool idea. Do you think we could maybe pass baseUrl from constructor so that we don't have to specify baseUrl every time?

devmaslove commented 2 years ago

This is cool idea. Do you think we could maybe pass baseUrl from constructor so that we don't have to specify baseUrl every time?

I think you need to make an additional function aka "downloadUrlFromDirectusSingelton" (need to think about the name, this is just for example) that will take the "baseUrl" value through the Directus singleton. But that's a different task.

devmaslove commented 2 years ago

Or you can move downloadUrl function from File object to Directus: downloadUrl(DirectusFile file)

devmaslove commented 2 years ago

I think it is not necessary to pass to the constructor. Need the ability to simply copy/save/load objects.

apstanisic commented 2 years ago

You're right. Maybe this kinda functionality should be added to src/modules/files/files_handler.dart, probably another method to download that file.