Mèo Béo
Mèo Béo

Reputation: 111

How to save images with an object in Play framework 2.0 + java + mysql

As the tittle.How the simple way to save images with an object and display them?

Sry if my question is ugly. i'm new with Play framework :(

Upvotes: 0

Views: 1745

Answers (2)

Jakob
Jakob

Reputation: 749

For file uploads with play and java check:
http://www.playframework.com/documentation/2.0/JavaFileUpload

and for saving that file in a DB check:
http://cyberasylum.janithw.com/saving-files-to-mysql-databases-using-java/

Upvotes: 0

biesior
biesior

Reputation: 55798

After upload just save the image preferably in the file system (not directly in the app) or even in some external CDN/cloud storage and then save its path in DB as a common String.

So you can use for an example some lightweight HTTP server for serving the files or even use Play's streaming possibilities as described in the doc - in section Serving files.

Of course if you'll store the file in external service like CDN, all you need to do is place absolute path in the src attribute of the img tag.

Upvotes: 2

Related Questions