public String addMediaEntry(final Entry entry, final String slug, final InputStream is) throws Exception {
        synchronized (FileStore.getFileStore()) {

            // Save media file temp file
            final Content content = entry.getContents().get(0);
            if (entry.getTitle() == null) {
                entry.setTitle(slug);
            }
            final String fileName = createFileName(slug != null ? slug : entry.getTitle(), content.getType());
            final File tempFile = File.createTempFile(fileName, "tmp");
            final FileOutputStream fos = new FileOutputStream(tempFile);
            Utilities.copyInputToOutput(is, fos);
            fos.close();

            // Save media file
            final FileInputStream fis = new FileInputStream(tempFile);
            saveMediaFile(fileName, content.getType(), tempFile.length(), fis);
            fis.close();
            final File resourceFile = new File(getEntryMediaPath(fileName));

            // Create media-link entry
            updateTimestamps(entry);

            // Save media-link entry
            final String entryPath = getEntryPath(fileName);
            final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
            updateMediaEntryAppLinks(entry, resourceFile.getName(), true);
            Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
            os.flush();
            os.close();

            // Update feed with new entry
            final Feed f = getFeedDocument();
            updateMediaEntryAppLinks(entry, resourceFile.getName(), false);
            updateFeedDocumentWithNewEntry(f, entry);

            return getEntryEditURI(fileName, false, true);
        }
    }
public String addMediaEntry ( final Entry entry , final String slug , final InputStream is ) throws Exception { synchronized ( FileStore . getFileStore ( ) ) { final Content content = entry . getContents ( ) . get ( 0 ) ; if ( entry . getTitle ( ) == null ) { entry . setTitle ( slug ) ; } final String fileName = createFileName ( slug != null ? slug : entry . getTitle ( ) , content . getType ( ) ) ; final File tempFile = File . createTempFile ( fileName , "tmp" ) ; final FileOutputStream fos = new FileOutputStream ( tempFile ) ; Utilities . copyInputToOutput ( is , fos ) ; fos . close ( ) ; final FileInputStream fis = new FileInputStream ( tempFile ) ; saveMediaFile ( fileName , content . getType ( ) , tempFile . length ( ) , fis ) ; fis . close ( ) ; final File resourceFile = new File ( getEntryMediaPath ( fileName ) ) ; updateTimestamps ( entry ) ; final String entryPath = getEntryPath ( fileName ) ; final OutputStream os = FileStore . getFileStore ( ) . getFileOutputStream ( entryPath ) ; updateMediaEntryAppLinks ( entry , resourceFile . getName ( ) , true ) ; Atom10Generator . serializeEntry ( entry , new OutputStreamWriter ( os , "UTF-8" ) ) ; os . flush ( ) ; os . close ( ) ; final Feed f = getFeedDocument ( ) ; updateMediaEntryAppLinks ( entry , resourceFile . getName ( ) , false ) ; updateFeedDocumentWithNewEntry ( f , entry ) ; return getEntryEditURI ( fileName , false , true ) ; } }
Add media entry to collection. Accepts a media file to be added to collection. The file will
be saved to disk in a directory under the collection's directory and the path will follow the
pattern <code>[collection-plural]/[entryid]/media/[entryid]</code>. An Atom entry will be
created to store metadata for the entry and it will exist at the path
<code>[collection-plural]/[entryid]/entry.xml</code>. The entry will be added to the
collection's feed in [collection-plural]/feed.xml.

@param entry Entry object
@param slug String to be used in file-name
@param is Source of media data
@throws java.lang.Exception On Error
@return Location URI of entry