[ALF-21813] MIME type does not change when the content is changed Created: 29-Dec-16  Updated: 24-Mar-20  Resolved: 26-Jan-17

Status: Closed
Project: Alfresco
Component/s: Repository
Affects Version/s: 5.1
Fix Version/s: Community Edition 201702 GA
Security Level: external (External user)

Type: Bug Priority: Critical
Reporter: Douglas Cassiano Rodrigues Paes Assignee: Closed Issues
Resolution: Fixed Votes: 1
Labels: PatchAttached
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive mimetype-change-test.zip    
Issue Links:
Related
relates to MNT-14924 Upload new version with different fil... Closed
relates to MNT-16328 CLONE Cloud - Upload new version with... Closed
Date of First Response:

 Description   

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):
Creating DOCX
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)

Suggested fix
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.


 Comments   
Comment by Richard Esplin [X] (Inactive) [ 19-Jan-17 ]

Thank you for reporting this issue. Can you reproduce it on the latest release of Community Edition?

Your report suggests that it is fixed in 5.2, so is this issue simply documenting the problem for other people and we can close it?

Comment by Richard Esplin [X] (Inactive) [ 26-Jan-17 ]

Douglas explained to me that he didn't test this in 5.2, but the code that addresses it appears to be in 5.2.

This was fixed as part of a service pack (see MNT-14924) and is still being merged to all Enterprise Edition releases. We believe that it is fixed in the current releases of Community Edition.

Comment by Douglas Cassiano Rodrigues Paes [ 24-Apr-17 ]

@resplin I am back just to let you know that everything is worked ok on 201702-GA.

I have just tried uploading a new PDF over a DOCX file, and both mime type and extension got changed.

Thank you.

Generated at Tue May 18 05:58:02 BST 2021 using Jira 7.13.15#713015-sha1:7c5ddd2c3e1709974ae9c48c17df8edd3919fe2c.