public Entry updateMediaEntry ( final String fileName , final String contentType , final InputStream is ) throws Exception { synchronized ( FileStore . getFileStore ( ) ) { final File tempFile = File . createTempFile ( fileName , "tmp" ) ; final FileOutputStream fos = new FileOutputStream ( tempFile ) ; Utilities . copyInputToOutput ( is , fos ) ; fos . close ( ) ; // Update media file final FileInputStream fis = new FileInputStream ( tempFile ) ; saveMediaFile ( fileName , contentType , tempFile . length ( ) , fis ) ; fis . close ( ) ; final File resourceFile = new File ( getEntryMediaPath ( fileName ) ) ; // Load media-link entry to return final String entryPath = getEntryPath ( fileName ) ; final InputStream in = FileStore . getFileStore ( ) . getFileInputStream ( entryPath ) ; final Entry atomEntry = loadAtomResourceEntry ( in , resourceFile ) ; updateTimestamps ( atomEntry ) ; updateMediaEntryAppLinks ( atomEntry , fileName , false ) ; // Update feed with new entry final Feed f = getFeedDocument ( ) ; updateFeedDocumentWithExistingEntry ( f , atomEntry ) ; // Save updated media-link entry final OutputStream os = FileStore . getFileStore ( ) . getFileOutputStream ( entryPath ) ; updateMediaEntryAppLinks ( atomEntry , fileName , true ) ; Atom10Generator . serializeEntry ( atomEntry , new OutputStreamWriter ( os , "UTF-8" ) ) ; os . flush ( ) ; os . close ( ) ; return atomEntry ; } }
Update media associated with a media - link entry .