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
Can't download text file #7572
Comments
Thanks for opening this issue!
|
Thanks for opening this issue! I can imagine that people have different expectations, depending on how they use the dashboard. Some may want an image for example to be displayed immediately in the browser, others may want it to be downloaded. Changing this one way or the other may disrupt or improve someone's workflow. Browsers usually have an option to to download a resource instead of displaying it directly in the browser. For example in Safari on macOS, if you hold the option key while clicking on a link, the browser decides to download it, regardless of what the server recommends. You can try this out by going here and clicking the Conversely, I don't think browsers do have an easily accessible shortcut to display a resource in a browser. So it may make more sense to keep the current behavior of opening resources in the browser by default and give the user the option to use a browser shortcut to download a resource. |
@igor-lemon can this issue be closed? |
If you think that it isn't a popular solution you can close the issue and close the PR. |
It changes the behavior, but how can we decide which behavior should be preferred? If I read the PR correctly, it sets the content-disposition header to Instead of hard-coding whether the header should be Alternatively, there is also the HTML |
Maybe my needs are exclusive, but I really don't need to show the file in a browser. |
And why don't you use the |
Because it doesn't work :) |
What do you mean by "not strong path"? |
Sorry, not a direct path |
Do you mean the path points directly to S3 and not via Parse Server? |
Oh, no, I found a problem... new Parse.File(`${id}.data`, { base64: base64data }, 'binary/octet-stream'); It doesn't work... |
So, I can propose 2 ways:
|
Hi @mtrezza! |
Maybe let's go one step back just to think this through. Looking at your code you already set the file type when uploading the data to the server: new Parse.File(`${id}.data`, { base64: base64data }, 'binary/octet-stream'); There are two ways of retrieving the file:
In case of (a), is the file type preserved, so that the issue only occurs for (b)? |
Check the code in PR. |
Then what's the point of setting the content type when saving the file in: new Parse.File(`${id}.data`, { base64: base64data }, 'binary/octet-stream'); |
This question is not for me, you can ask your friends who developed it, why they write that I can set the content type of the file but when I want to download this file parse server return trash in the headers. |
That's a good one 🙂 I thought you maybe know more since you looked into this. Before merging the PR we need to understand what we currently have. If one can set the content type when uploading a file, it shouldn't have to be "guessed" again when downloading it. So the next step would be to look into the JS SDK and find out what that content type parameter is used for. Do you want to take a look? |
Yep. I checked the problem just on the Parse Server part, JS SDK works well and content type very important param. $ file --mime-type lic.data
lic.data: application/octet-stream But when we want to download this file, the parse server just checks the extension from the file name. But if |
Do you know whether the context type is stored as a parameter of the I think the priorities could be:
I'm not sure what the side effects are when adding a fallback to That's why I'm thinking fixing (1) would solve the issue you mention and maybe also fix a bug. |
Yes, I think that our conversation is going a little in the wrong direction. I do not need help to solve my issues, I just want to convey that the parse-server returns the wrong content type in the headers, which is based only on the file extension from the file name, and not on the real type. As I wrote above, the best option would be to get the mime info of an uploaded file and return it, but it isn't a little work and I have no desire to do it because we can't even agree on a simple hotfix in 1 line that solves 99% cases. |
Maybe you are a little misled, this issue I created just because you request an issue for a pull request. I don’t need to solve any own issues here. :) |
The issue discussion here should justify the PR, not the other way around. That's why opening an issue is a requirement. Maybe we can clarify that in the PR template. The issue I see is that your suggestion means setting an incorrect content type in some cases if the content type cannot be determined. What is the argument for that and why wouldn't it be better to not specify a content type at all instead of an incorrect one? |
Perhaps we could add the option
|
Wouldn't that be something one wants to determine on a per-file basis? |
Probably, which I assume would come when we have a beforeGetFile trigger |
That sounds like an exciting idea! |
What are your thoughts? I think that the file get triggers have their own considerations and concerns, but it's probably the most versatile approach to this issue |
Yep, agree |
New Issue Checklist
Issue Description
Can't download a text file. The file opens in a browser, I need to save it manually.
Steps to reproduce
Upload some text file. Try to download it by link.
Actual Outcome
Expected Outcome
I want to download the file immediantly.
Environment
Server
FILL_THIS_OUT
FILL_THIS_OUT
FILL_THIS_OUT
Database
FILL_THIS_OUT
FILL_THIS_OUT
FILL_THIS_OUT
Client
FILL_THIS_OUT
FILL_THIS_OUT
Logs
The text was updated successfully, but these errors were encountered: