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

How to download a file from a content store #16

Closed
estebes opened this issue Oct 30, 2017 · 8 comments
Closed

How to download a file from a content store #16

estebes opened this issue Oct 30, 2017 · 8 comments

Comments

@estebes
Copy link

estebes commented Oct 30, 2017

When i try to download a file from the server onto the disk i get an error saying server problem and in the server log i get "java.lang.UnsupportedOperationException: null
"

@paulcwarren
Copy link
Owner

@estebes is there anymore stack trace than that? What Spring Content Module(s) are you using? Spring Content for JPA? And are you also using Spring Content REST?

A small project that reproduces this issue would be very helpful as well.

You could also cross reference your project against the relevant example in github.com/paulcwarren/spring-content-examples

@estebes
Copy link
Author

estebes commented Oct 30, 2017

Full log - https://pastebin.com/1rtRt1QR

Dependencies
// Spring Content >> /* https://mvnrepository.com/artifact/com.github.paulcwarren/spring-content-fs-boot-starter */ compile group: 'com.github.paulcwarren', name: 'spring-content-fs-boot-starter', version: '0.0.7-SNAPSHOT' /* https://mvnrepository.com/artifact/com.github.paulcwarren/spring-content-rest-boot-starter */ compile group: 'com.github.paulcwarren', name: 'spring-content-rest-boot-starter', version: '0.0.7-SNAPSHOT' // << Spring Content

Html code
<a href="file.pdf" download>download here</a>
This also happens when i open the content in a new tab and click save as.

I'll try to create a small project reproducing the issue.

@paulcwarren
Copy link
Owner

A project may not be necessary @estebes.

I have a theory. When you click that 'download' I think your browser might not be sending an Accept header in the request. In ContentEntityRestController (

) we call a spring class to parse the mime-types received in the request's accept header. If there aren't any it returns an immmutable list that we then try and add to. This throws the UnsupportedOperationException.

So I wonder what browser you are using and whether you could check the request it is sending.

Look forward to hearing from you.

@paulcwarren
Copy link
Owner

Yeah, I think that is what is going on. I just managed to reproduce that error in a unit tests anyways. Your context will be helpful but i am going to go ahead and fix this as it is a bug anyways.

@estebes
Copy link
Author

estebes commented Oct 30, 2017

So i just tried to use firefox instead of chrome and it actually works on firefox althoughit ignores the .pdf extension and downloads a .txt but yes what you described seems to be what is happening.

@paulcwarren
Copy link
Owner

I added a candidate fix for this issue in this commit:-

294fa48

Can you switchover to 0.0.8-SNAPSHOT and give it a whirl. If it fixes the issue then I'll cut a release.

@estebes
Copy link
Author

estebes commented Oct 31, 2017

Perfect fix. Works on both chrome and firefox. I think i can now close this issue. Thank you very much for the help.

@estebes estebes closed this as completed Oct 31, 2017
@paulcwarren
Copy link
Owner

+1

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

2 participants