@ Override public Entry postMedia ( final AtomRequest areq , final Entry entry ) throws AtomException { // get incoming slug from HTTP header final String slug = areq . getHeader ( "Slug" ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "postMedia - title: " + entry . getTitle ( ) + " slug:" + slug ) ; } try { final File tempFile = null ; final String [ ] pathInfo = StringUtils . split ( areq . getPathInfo ( ) , "/" ) ; final String handle = pathInfo [ 0 ] ; final String collection = pathInfo [ 1 ] ; final FileBasedCollection col = service . findCollectionByHandle ( handle , collection ) ; try { col . addMediaEntry ( entry , slug , areq . getInputStream ( ) ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; final String msg = "ERROR reading posted file" ; LOG . error ( msg , e ) ; throw new AtomException ( msg , e ) ; } finally { if ( tempFile != null ) { tempFile . delete ( ) ; } } } catch ( final Exception re ) { throw new AtomException ( "ERROR: posting media" ) ; } return entry ; }
Store media data in collection specified by pathInfo create an Atom media - link entry to store metadata for the new media file and return that entry to the caller .