mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.0/Cloud)
85941: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud) 85882: Merged DEV to V4.2-BUG-FIX (4.2.4) 74616 : MNT-11704 : Updating Adobe Illustrator and Photoshop Documents results in loss of mimetype and preview capability - Guess mimetype using content of uploaded new file git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94520 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -3767,6 +3767,11 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
||||
* the Content object as supplied.
|
||||
*/
|
||||
public void write(Content content, boolean applyMimetype, boolean guessEncoding)
|
||||
{
|
||||
write(content, applyMimetype, guessEncoding, false);
|
||||
}
|
||||
|
||||
public void write(Content content, boolean applyMimetype, boolean guessEncoding, boolean guessMimetype)
|
||||
{
|
||||
ContentService contentService = services.getContentService();
|
||||
ContentWriter writer = contentService.getWriter(nodeRef, this.property, true);
|
||||
@@ -3775,6 +3780,19 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
||||
{
|
||||
writer.setMimetype(content.getMimetype());
|
||||
}
|
||||
if (guessMimetype)
|
||||
{
|
||||
InputStream reuseableIS = new ReuseableInputStream(content.getInputStream());
|
||||
writer.setMimetype(services.getMimetypeService().guessMimetype(getName(), reuseableIS));
|
||||
try
|
||||
{
|
||||
reuseableIS.reset();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (guessEncoding)
|
||||
{
|
||||
is = new BufferedInputStream(content.getInputStream());
|
||||
@@ -3949,6 +3967,31 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
||||
|
||||
private ContentData contentData;
|
||||
private QName property;
|
||||
|
||||
public class ReuseableInputStream extends BufferedInputStream
|
||||
{
|
||||
InputStream decorated;
|
||||
|
||||
ReuseableInputStream(InputStream decorated)
|
||||
{
|
||||
super(decorated);
|
||||
|
||||
decorated.mark(1024);
|
||||
|
||||
this.decorated = decorated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
decorated.reset();
|
||||
}
|
||||
|
||||
public void close(boolean force) throws IOException
|
||||
{
|
||||
decorated.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user