-
-
Save msegeya/11088123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Application extends Controller { | |
public static void index() { | |
render(); | |
} | |
public static void uploadPicture(Picture picture) { | |
picture.save(); | |
index(); | |
} | |
public static void getPicture(long id) { | |
Picture picture = Picture.findById(id); | |
response.setContentTypeIfNotSet(picture.image.type()); | |
renderBinary(picture.image.get()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
#{list items:models.Picture.findAll(), as:'picture'} | |
<li>${picture.id} <img src="@{Application.getPicture(picture.id)}" /></li> | |
#{/list} | |
</ul> | |
#{form @Application.uploadPicture(), enctype:'multipart/form-data'} | |
<input type="file" name="picture.image" /> | |
<input type="submit" name="submit" value="Save" /> | |
#{/form} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Picture extends Model { | |
public Blob image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment