Page 1 of 1

Is it possible to use Static Asset service in front site?

Posted: Sun Nov 25, 2012 12:55 pm
by aaron8tang
I'm running the demo site, and wanna add some new feature to the front site.

For example, let a customer upload his avatar picture.

Is it possible to use Static Asset service to do that, using the asset upload dialog to upload avatar pictures, using the static asset service to manage avatar pictures?

If it is, how to do that?

Thanks.

Re: Is it possible to use Static Asset service in front site?

Posted: Fri Dec 07, 2012 10:58 am
by jefffischer
While it's possible, it will require a bit of work. The best path would likely be:

1) Create a new admin module that only includes the asset view and presenter
2) Relax the permissions on this module to allow people other than admin users to get in (need to make anonymous access allowed in spring security for this destination)
3) Use a custom persistence handler for static asset usage that filters asset access to the avatar image type alone (protect your other assets from standard users)

The specifics of how to do this are beyond the scope of what I can describe in this post and the endeavor is intricate enough that it's not suitable for the light hearted. Having said that, I can point you at org.broadleafcommerce.cms.admin.client.ContentManagementModule for inspiration.

Perhaps something more straightfoward would be to create your own image upload function for your users. On the server side, simply use the API provided by StaticAssetService to persist your image. Then, you would have the full power of the asset server at your disposal. See the add method of StaticAssetCustomPersistenceHandler for inspiration.