Example usage for com.liferay.portal.kernel.util Constants GET_TEMP

List of usage examples for com.liferay.portal.kernel.util Constants GET_TEMP

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Constants GET_TEMP.

Prototype

String GET_TEMP

To view the source code for com.liferay.portal.kernel.util Constants GET_TEMP.

Click Source Link

Usage

From source file:com.liferay.image.uploader.web.internal.portlet.action.UploadImageMVCResourceCommand.java

License:Open Source License

@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws Exception {

    try {/*from w  w w .  ja v a  2s . c  o  m*/
        String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);

        if (cmd.equals(Constants.GET_TEMP)) {
            FileEntry tempFileEntry = UploadImageUtil.getTempImageFileEntry(resourceRequest);

            FlashMagicBytesUtil.Result flashMagicBytesUtilResult = FlashMagicBytesUtil
                    .check(tempFileEntry.getContentStream());

            if (flashMagicBytesUtilResult.isFlash()) {
                return;
            }

            serveTempImageFile(resourceResponse, flashMagicBytesUtilResult.getInputStream());
        }
    } catch (NoSuchFileEntryException nsfee) {

        // LPS-52675

        if (_log.isDebugEnabled()) {
            _log.debug(nsfee, nsfee);
        }
    } catch (Exception e) {
        _log.error("Unable to serve resource", e);
    }
}