Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

DMI file download IE error

$
0
0
SmartGWT 3.0
v8.2p_2012-10-11/PowerEdition Deployment (built 2012-10-11)


Hello,

I am downloading files from the server via DMI and I am stuck on the IE Error attached ("IE cannot download IDACall ...")
When this error occurs, my application is non-responsive and I have to hit refresh. Upon refresh, it would appear that the download works as expected without IE errors.

Looking this error up online, I did find some stuff with regards to downloading files over https with cache preventing headers but unfortunately that is not my case.


I am sure that the following DMI method executes successfully with no exceptions thrown.

Code:

public void downloadFile(final DSRequest dsRequest,
                      final HttpServletRequest request)
{
        dsRequest.rpc.doCustomResponse();
        final HttpServletResponse servletResponse =
                        dsRequest.rpc.getContext().response;

        long fileId = 0;

        if(dsRequest.getCriteria().get("fileId") != null &&
                !"".equals(dsRequest.getCriteria().get("fileId").toString()))
        {
            fileId = Long.parseLong(dsRequest.getCriteria().get("fileId").toString());
        }

        AssociatedFileDto fileDto = null;
        try
        {
            fileDto = situationService.retrieveAssociatedFileById(fileId);
            if(fileDto != null)
            {
                final byte[] bytes = fileDto.getData();
                final String filename = fileDto.getFileName();
                servletResponse.setHeader("Pragma", "private");
                servletResponse.setHeader("Cache-Control", "private, must-revalidate");
                if("text/plain".equals(fileDto.getMimeType()))
                {
                    servletResponse.setContentType("text/html");
                }
                else
                {
                    servletResponse.setContentType(fileDto.getMimeType());
                }
                servletResponse.setHeader("Content-Disposition", "attachment; filename="+ filename);
                servletResponse.setContentLength(bytes.length);
                servletResponse.getOutputStream().write(bytes);
            }
        }
        catch (final Exception e)
        {
            logger.error("There was an error while retrieving associated file with id: {}",fileId,e);
        }
}

Below is the piece of code on the front end that makes the request
Code:

DSRequest requestProperties = new DSRequest();
requestProperties.setDownloadResult(true);
requestProperties.setOperationId("downloadFile");
DataSourceFactory.getSitDetailsAssoFilesDataSource()
                .fetchData(new Criteria("fileId", fileId),null,requestProperties);

This is obviously not a defect with regards to SmartGWT rather than me missing something. Maybe configuration wise?
Any suggestions would be much appreciated

Regards,
Stathis

Attached Images
File Type: jpg dl-error.JPG (23.8 KB)

Viewing all articles
Browse latest Browse all 4756

Latest Images

Trending Articles



Latest Images