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

download with filename #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sidasmo
Copy link
Member

@sidasmo sidasmo commented Mar 24, 2022

use SONARURL/files/ID?dl=1 for download stream with filenames

@@ -81,7 +82,8 @@ class Files {
if (opts.range) {
opts.headers.Range = `bytes=${opts.range.from || 0}-${opts.range.to || ''}`
}
return this.collection.fetch('/file/' + id, opts)
const query = opts.query || ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fetch function being used here (client/lib/fetch.js) already supports a params option with an object to set query string in the URL. So lets not add anothet way here. Instead add a doc comment that passing { params: { dl: 1 }} option will set the Content-Disposition header to attachement with the filename provided at upload, making the browser treat the file as a download (and not display in the browser).

@Frando
Copy link
Member

Frando commented Mar 25, 2022

Looks good! Added one comment, can be merged once that is addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants