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

[github] Downloading markdown file adds .html prefix #382

Closed
brianjgeiger opened this issue Mar 8, 2014 · 17 comments
Closed

[github] Downloading markdown file adds .html prefix #382

brianjgeiger opened this issue Mar 8, 2014 · 17 comments
Assignees

Comments

@brianjgeiger
Copy link
Collaborator

Steps

  1. Go to a project with a github store
  2. Go to the file tab
  3. Add a markdown (.md) file to a github store.
  4. Add the same file to the OSF store.
  5. Download from github store using screen shot 2014-03-08 at 12 08 10 pm
  6. Download from OSF store using screen shot 2014-03-08 at 12 08 10 pm

Expected

You will get two files with essentially the same name (with an operating system appended marker to keep them from overwriting or whatever)

Actual

The OSF file downloads as filename.md. The github file downloads as filename.md.html

Possible Cause

Usually this sort of thing is that the mime type is not set properly for download.

Environment

This bug was found with Safari 7.1 (9537.85.10.17.1) on Mac OS X 10.9.5.

@brianjgeiger
Copy link
Collaborator Author

Same thing happens with .txt files.

@JeffSpies JeffSpies added this to the Post-Milestone milestone Mar 8, 2014
@JeffSpies JeffSpies added bug and removed bug labels Mar 8, 2014
@JeffSpies JeffSpies assigned jmcarp and unassigned jmcarp Mar 8, 2014
@caileyfitz
Copy link
Contributor

Hey @brianjgeiger - are you still having this problem? I can't seem to replicate it.

@brianjgeiger
Copy link
Collaborator Author

I'll give it a try, but I suspect it's been incidentally fixed by now.

@brianjgeiger
Copy link
Collaborator Author

No, not fixed, but has to be on a github store, not an OSF store. OSF store works properly still. Verified on Production. See https://osf.io/nqxz6/files/

@caileyfitz
Copy link
Contributor

Maybe I'm doing something wrong, but I still can't get this problem. I downloaded all of these files, and here's what I see:
screen shot 2014-09-24 at 3 02 48 pm
Is this not what you see in your downloads window?

@brianjgeiger
Copy link
Collaborator Author

Are you using Chrome? Try with Safari. I will update the description of the bug to indicate that.

@brianjgeiger
Copy link
Collaborator Author

screen shot 2014-09-24 at 3 07 03 pm

@caileyfitz
Copy link
Contributor

Yes - I was using Chrome at first. Using Safari, I get the error, but mine looks like this
screen shot 2014-09-24 at 3 08 49 pm
Perhaps this is trivial, but note the difference with my files having a Chrome logo instead of Safari, despite downloading them in Safari.

@brianjgeiger
Copy link
Collaborator Author

That'll just be because your system is set to open HTML files in Chrome instead of Safari.

@brianjgeiger
Copy link
Collaborator Author

I think I have a fix for the .txt file case. For markdown files, I believe we need to add a file with new mimetypes. @sloria, do you have a preference on where in the OSF hierarchy such a file would go?

@brianjgeiger
Copy link
Collaborator Author

Going to poke around the github api first to see if they provide content-type.

@brianjgeiger
Copy link
Collaborator Author

Oh, this is a lot worse than I thought, or it's gotten worse in recent months. On staging, if I try to download, say, a png, it tries to do it as html. Production as well.

@brianjgeiger
Copy link
Collaborator Author

I can't find a way with the Github API to get the mimetype of the file.

With using the default mimetype guessing, it fixes most of the cases. Markdown gets labelled as a text file rather than just .md or .markdown, so probably we will still want to use a custom mime file for this and any future cases as new filetypes are added. There is some system-dependence here, so linux may have a different set of mimetypes than OS X does. But for the most flexibility, at least having our own file will let us handle the cases where things aren't dealt with by the built-in stuff.

@JeffSpies
Copy link
Contributor

Can't we just force this? @Lyndsy you dealt with something similar, right?

On Thu, Sep 25, 2014 at 3:42 PM, Brian J. Geiger [email protected]
wrote:

I can't find a way with the Github API to get the mimetype of the file.

With using the default mimetype guessing, it fixes most of the cases.
Markdown gets labelled as a text file rather than just .md or .markdown, so
probably we will still want to use a custom mime file for this and any
future cases as new filetypes are added. There is some system-dependence
here, so linux may have a different set of mimetypes than OS X does. But
for the most flexibility, at least having our own file will let us handle
the cases where things aren't dealt with by the built-in stuff.


Reply to this email directly or view it on GitHub
#382 (comment)
.

@brianjgeiger
Copy link
Collaborator Author

That's essentially what this is doing. You have to send the content-type with the file. Most of the plugins already have this info, but the github api doesn't seem to provide it. Chrome apparently guesses the mimetype come what may, which is why nobody noticed, but Safari does not, or something about the content-type that is being sent keeps Safari from wanting to.

The above commit handles cases of file extensions that the OS knows about, it's just that .md isn't one of those.

@brianjgeiger
Copy link
Collaborator Author

There was a default case that was too specific (checking for file extension being missing). I made it fit with what we're doing now, and it works much better.

@sloria
Copy link
Contributor

sloria commented Sep 29, 2014

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

No branches or pull requests

7 participants