-
Notifications
You must be signed in to change notification settings - Fork 67
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 do I add a REST API to read a mp3 file from the predefined folder #521
Comments
Hi @BhanuPrakash531, Thanks for raising this issue. Laying content URIs over entity URIs such as It is possible that we could support PUTing to |
Hi @BhanuPrakash531 again. Further to my previous response. There is a way to get the job done here. Although it means compromising on the content URI. You had previously mentioned using /dvds/<id}/image. But if you add a ImageRepository (and StreamRepository) then you can manage the content directly by:
to create a new instance of an Image, then:
to set the content, and:
to fetch it again. However, under this alternative you will be responsible for associating the Dvd entity with the Image entity. HTH |
Thanks @paulcwarren for the detailed explanation. It helped. We can work with this. Also on another project, we have a list of mp3s in resources folder and we don't have any feature to add more mp3s or images. We just need to fetch it from the resources folder where the filename will be set in the pojo on a database and stream it to the UI. What is the best way to do this as per your expert advise? Thanks in advance |
For your second use case it sounds like you probably just need a
Which essentially is just a Spring ResourceLoader. Providing a Java API to fetch content by filename (rather than entity); i.e. The Spring Content REST endpoints for a
Then you can iterate the filenames from the database and for each make requests (or getResource calls) in order to fetch your content. But honestly, if your resource aren't dynamic at all and the resources are just stored on the filesystem you might just be better off using something like this. HTH |
Closing due to inactivity. Feel free to re-open if you would like more help. |
I have a list of mp3s in my resource folder, I have a JPA implementation with multiple entities. I need to store the filename of the mp3 in the database as part of an entity and I need to read these mp3 as a REST APIs. Please help.
Trying to do as per this example. Spring Content REST but I'm not getting the /dvds/1/image endpoint, server rejects with the error
<dependency> <groupId>com.github.paulcwarren</groupId> <artifactId>spring-content-fs-boot-starter</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>com.github.paulcwarren</groupId> <artifactId>spring-content-rest-boot-starter</artifactId> <version>1.2.2</version> </dependency>
Please let me know what is the issue.
Thanks in advance.
The text was updated successfully, but these errors were encountered: