When an user wants to upload a new version for an existing document using a different mimetype, Alfresco does not update the extension or the mime type property.
I tried to apply the solution presented https://github.com/keensoft/alfresco-summit-2014/tree/master/10-enhancements/08-rename-on-change-ext/rename-on-change-ext-repo
but I found out that the behaviour does not work, as the values from before and after are, in different execution (it's being fired for every event):
before NULL, after DOCX
Uploading a PDF
before NULL, after DOCX
before DOCX, after DOCX
before PDF, after PDF
Because of that, there is no way to detect the change with the behaviour.
The problem is that the upload webscript is ignoring the mime type.
Based on that, I have back ported the upload webscript controller from 5.2, and made some changes, and now, combining the behaviour AND the upload controller, it's working, having Alfresco correctly setting both the extension and the mime type property.
I have a sample project that can be used to simulate the problem I'm describing here. I'm attaching it to this issue.
This problem is related with the issue reported at https://issues.alfresco.com/jira/browse/MNT-16328
All the changes I made on the upload.js file are marked by comments starting with DGCloud.
The exptected behaviour:
Create: document.docx (extension docx and mime type microsoft office)
Upload: document.pdf (extension pdf and mime type adobe pdf)
Upload: image.jpg (extension jpg and mime type jpg)
The current behaviour:
Create: document.docx (extension docx and mime tpe microsoft office)
Upload: document.pdf (extension remains docx and mime type microsoft office)
Simply back porting the upload.js file and changing the update name and mime type is not enough, as the upload.js will also update the full name, and that's not the behavior we need.
All we need is that the base name remains, and the extension and mime type are changed.
In order to "fix" that, I have commented the line 289, //updateNode.setName(newFilename);
I hope this can help you to understand the problem.
Notes from the reporter:
- Previous values are not injected properly to ContentServicePolicies.
- OnContentPropertyUpdatePolicy event does not fire when uploading a new version using a different mime type
- The 5.2 code appears to address the problem, though I haven't yet tested in that release.