Issue
- Steps to reproduce:
- Add a new blogs entry
- Add a new cover image to this blogs entry
- Save the entry
- Expected behavior: The image is uploaded
- Current behavior: An error is thrown and you found an error similar to this in your logs:
ERROR com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand - com.liferay.portal.kernel.exception.PortalException: Unable to get a unique file name for image.png in folder 75309953
com.liferay.portal.kernel.exception.PortalException: Unable to get a unique file name for image.png in folder 75309953
at com.liferay.portlet.blogs.BlogsEntryAttachmentFileEntryHelper.getUniqueFileName(BlogsEntryAttachmentFileEntryHelper.java:206)
at com.liferay.portlet.blogs.BlogsEntryAttachmentFileEntryHelper.addBlogsEntryAttachmentFileEntry(BlogsEntryAttachmentFileEntryHelper.java:100)
at com.liferay.portlet.blogs.BlogsEntryAttachmentFileEntryHelper.addBlogsEntryAttachmentFileEntries(BlogsEntryAttachmentFileEntryHelper.java:55)
at com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.updateEntry(EditEntryMVCActionCommand.java:548)
at com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand$UpdateEntryCallable.call(EditEntryMVCActionCommand.java:677)
at com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand$UpdateEntryCallable.call(EditEntryMVCActionCommand.java:673)
at com.liferay.portal.spring.transaction.TransactionInvokerImpl$CallableMethodInvocation.proceed(TransactionInvokerImpl.java:101)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:54)
at com.liferay.portal.spring.transaction.TransactionInvokerImpl.invoke(TransactionInvokerImpl.java:47)
at com.liferay.portal.kernel.transaction.TransactionInvokerUtil.invoke(TransactionInvokerUtil.java:28)
at com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.doProcessAction(EditEntryMVCActionCommand.java:192)
at com.liferay.portal.kernel.portlet.bridges.mvc.BaseMVCActionCommand.processAction(BaseMVCActionCommand.java:61)
at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:380)
at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:93)
at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:260)
Environment
- 7.0+
Resolution
- Blogs attachments are stored in a common folder. Because of that, Liferay handles the name collision adding a suffix to the files if a used name is detected.
- Anyway, to avoid performance problems, we limit this autogenerated names to 50.
- To confirm if that's your case you could run a script similar to CheckBlogsUniqueFileNameLogic.groovy, based in the BlogsEntryLocalServiceImpl#getUniqueFileName method logic (it could differ depending on the Liferay version).
- You only have to adjust this variables to the proper ones:
def groupId = [group id]Ldef fileName = "[name of the file]"def folderId = [folder id]L - And execute it.
- Once it is done, you could see detailed info of the process with the exception at the end.
- If you find that you reach the 50 elements limit before the Exception is thrown...
image (50).png
- ...then you've confirm that you've reach the file name autogeneration limit.
- To solve (or avoid) the problem you could remove the unused images or avoid using this name in the future.
- Our suggestion is try to use the most descriptive image name in all the cases to minimize the collisions.
- Due it has impact in the performance, we do not recomend to customize this limit.
Additional Information