Fórum

Images saving in folder but not appearing in the image library

simon maskell, modificado 12 Anos atrás.

Images saving in folder but not appearing in the image library

New Member Postagens: 5 Data de Entrada: 27/03/12 Postagens Recentes
Hi

The below code uses the lfr-upload-container id class which works well apart from it is saving the images into c:\portal\liferay-portal-6.0.6\data\images\74\30 directory and not showing in the image library.

Can some one have a look at see what I am doing wrong?

Thanks in advance

Simon



View.jsp

<liferay-theme:defineObjects />
<DIV class=lfr-upload-container id="<portlet:namespace />testaui_holder"></DIV>


<aui:script use="liferay-upload">
new Liferay.Upload({
allowedFileTypes: '*.*',
container: '#<portlet:namespace />testaui_holder',
maxFileSize: 1024,
namespace:'<portlet:namespace />',
uploadFile: '<liferay-portlet:actionURL windowState="pop_up" name="editImage" doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/image_gallery/edit_image" /></liferay-portlet:actionURL>',
buttonHeight: 100,

buttonWidth: 100,
fallbackContainer: '#<portlet:namespace />testaui_fallback',
});
</aui:script>





public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {

FileItemFactory factory = new DiskFileItemFactory();
PortletFileUpload upload = new PortletFileUpload(factory);
List<FileItem> items=null;
try {
items = upload.parseRequest(actionRequest);
} catch (FileUploadException e) {
e.printStackTrace();
}
if(items!=null){
for (FileItem fi:items)
{
if(!fi.isFormField()){
FileItem fileItem = fi;
ImageBag imageBag = ImageProcessorUtil.read(FileUtil.getBytes(fileItem.getInputStream()));
RenderedImage renderedImage = imageBag.getRenderedImage();
long imageId;

try {

imageId = CounterLocalServiceUtil.increment();
ImageLocalServiceUtil.updateImage(imageId, ImageProcessorUtil.getBytes(renderedImage, imageBag.getType()));
} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
e.printStackTrace();
}
}
}
}
}
}
thumbnail
David H Nebinger, modificado 12 Anos atrás.

RE: Images saving in folder but not appearing in the image library

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
You need to add code to force the reindexing of images after the updateImage() method succeeds.
simon maskell, modificado 12 Anos atrás.

RE: Images saving in folder but not appearing in the image library

New Member Postagens: 5 Data de Entrada: 27/03/12 Postagens Recentes
Thanks David that has worked