Upload new version + mime type

cancel
Showing results for 
Search instead for 
Did you mean: 
kamilaw_
Member II

Upload new version + mime type

I have an empty document. Only metadata are filled.

I want to upload new version of document, e.g. newFile.docx.

It is OK.

But. 

The mime type is bin(application/octet-stream).

It's a bug? Or where is a problem? I'm really confused.

Alfresco Community 5.1

4 Replies
mehe
Senior Member II

Re: Upload new version + mime type

I think the repository doesn't do a second guess of the mime type if you create a new version.

You say, you have an empty document. Do know the mime type beforehand and are able to set it like you did with the rest of the metadata?

Another possibility would be a script executed by a rule on "incoming document".

Maybe an adapted scripts like in alfresco - convert docx to pdf and create a new version could help

kamilaw_
Member II

Re: Upload new version + mime type

Thank for your answer.

So, Alfresco create a .bin extension and it is bin to the end of days? Hm, not very clever.

I do not know extension beforehand.

My solution is a Java class: 


ContentReader contentReader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
String type = mimetypeService.guessMimetype(null, contentReader);
String extension = mimetypeService.getExtension(type);

But, it's not running with type .accdb or .txt.  Why?

mehe
Senior Member II

Re: Upload new version + mime type

I think alfresco just lacks the mimetype for MS Access accdb files.

/thread/182405-doesnt-alfresco-handle-ms-access-files

Axel Faust‌ commented on this.

The mimetype service is also able to guess the mimetype from the extension

mimetypeService.getMimetypesByExtension().get(extension);

It might be not very clever not to check and set the mimetype on new versions, but most likely you change a documents content, not its name and mimetype. So because your case is quite unusual, you won't find a out of the box solution.

I had such a case when metadata was waiting for files from a legacy application and solved it with a incoming rule, executing a short JavaScript...

you can add mimetypes to Alfresco: Adding a MIME type | Alfresco Documentation 

douglascrp
Advanced II

Re: Upload new version + mime type

This behaviour was changed in the 201702-GA release (Alfresco Content Repository 5.2.f and Alfresco Share 5.2.e)

Details here [ALF-21813] MIME type does not change when the content is changed - Alfresco JIRA