Using the approach Igor mentioned - which sounds great - does the AssetFactory cache the images or he would need to implement this if he wanted to?
_______________________ Everton Agner Ramos 2010/12/9 Michael Gentry <mgen...@masslight.net> > I took a more conventional approach. I created a DatabaseImage page > that streams the image from the database. > > In the TML of the page that wants to embed an image from the database: > > <img src="${imageLink}"/> > > In the Java: > > @Inject > private PageRenderLinkSource pageRenderLinkSource; > > public Link getImageLink() > { > String encryptedContext = DatabaseImage.encrypt(...); > return > pageRenderLinkSource.createPageRenderLinkWithContext(DatabaseImage.class, > encryptedContext); > } > > The encrypt method basically encrypts everything I need (table names, > primary keys, etc) to go find the database image and stuffs it into > the link's context. At runtime, I end up with requests from the > browser like: > > GET > /MyApp/databaseimage/$002faiNglawZWKGHKrl$002fgpKneotYRwaq9gMk3dPr5zQkW8KkoezyRBm0TutynHstG0$002fyn$002b6izoD$002f$002f9V$000a$002fqAXmUmgxQ$003d$003d > > Ugly URL, but it works. In the DatabaseImage page itself I have: > > public StreamResponse onActivate(String context) > { > ... > } > > that decrypts the encrypted context, finds the image blob stored in > the database, and streams it out as the response. > > mrg > > > On Thu, Dec 9, 2010 at 7:22 AM, Igor Drobiazko <igor.drobia...@gmail.com> > wrote: > > There is no documentation for it as this is not an often use case. > However, > > just provide you own implementation of AsssetFactory, build it or bind it > in > > your module and make the contribution: > > > > public void contributeAssetSource(MappedConfiguration<String, > > AssetFactory> configuration, @InjectService("DbAssetFactory") > AssetFactory > > dbAssetFactory) { > > configuration.add("db", dbAssetFactory); > > } > > > > Now it is up to you to implement the AssetFactory. > > > > On Thu, Dec 9, 2010 at 11:53 AM, Gunnar Eketrapp > > <gunnar.eketr...@gmail.com>wrote: > > > >> Hi! > >> > >> I would like to store uploaded images in the database and then use them > in > >> template files. > >> > >> Are there any examples of how to do this? I.e. how to define a new > >> AssetFactory and contribute it to the AssetSource service configuration. > >> > >> Thanks in advance, > >> Gunnar Eketrapp (from a very cold and snowy Stockholm) > >> > >> ================================== > >> The doc says ... > >> > >> New Asset Domains > >> > >> If you wish to create new domains for assets, for example to allow > assets > >> to > >> be stored on the file system or in a database, you may define a new > >> AssetFactory and contribute it to the AssetSource service configuration. > >> > >> =================================== > >> > > > > > > > > -- > > Best regards, > > > > Igor Drobiazko > > http://tapestry5.de > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >