Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DirectusFile.downloadUrl method #49

Open
reev-create opened this issue Jun 29, 2022 · 2 comments
Open

Improve DirectusFile.downloadUrl method #49

reev-create opened this issue Jun 29, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@reev-create
Copy link

String? downloadUrl(String baseUrl) {

File download URL should return the whole download URL along with concatenated auth token of the current user

@reev-create
Copy link
Author

reev-create commented Jun 29, 2022

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}';
}

@apstanisic
Copy link
Owner

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}).

@apstanisic apstanisic added enhancement New feature or request good first issue Good for newcomers labels Jun 29, 2022
@apstanisic apstanisic changed the title Request for authenticated url with tokens. Improve DirectusFile.downloadUrl method Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants