App download func, broken after 6.5.5 upgrade

Hi, I have some code that downloads files from both the file system and byte arrays in memory. It was working fine until i did the 6.5.5 upgrade.

I saw this in the release notes
“Application resources now use app:// URLs, similar to how theme resource URLs theme:// urls. Ensure Resource references are passed through the ApplicationConnection.translateVaadinUri() method on the client side. This might affect some add-ons”
.

It sounds like it might be related but seems to be focused at client-widgets,etc so not sure how it might be affecting my code.

This is some of my example code

public class ByteArrayResource extends StreamResource {

    private final String filename;
    private final String mimeType;

    public ByteArrayResource(byte[] byteArray, String name,String mimeType,Application application)
            throws FileNotFoundException {
        super(new ByteStreamResource(byteArray), name,
                application);

        this.filename = name;
        this.mimeType = mimeType;
    }

    public DownloadStream getStream() {
        DownloadStream stream = new DownloadStream(getStreamSource()
                .getStream(), mimeType, filename);
        stream.setParameter("Content-Disposition", "attachment;filename=\""
                + filename+"\"");
        return stream;
    }

    private static class ByteStreamResource implements
            StreamResource.StreamSource {

        private final InputStream inputStream;

        public ByteStreamResource(byte[] byteArray)
                throws FileNotFoundException {
            inputStream = new ByteArrayInputStream(byteArray);
        }

        public InputStream getStream() {
            return inputStream;
        }
    }
}

and it’s usage:


ByteArrayResource br = new ByteArrayResource(supDoc.getData(),supDoc.getName(),supDoc.getMimeType(),getApplication());
getApplication().getMainWindow().open(br, "_blank");

Any ideas on why this might not be working now?

Your problem could be the critical regression in the open() method in 6.5.5, see
#6849
. It was fixed on friday and we hope to get 6.5.6 out on monday.

Awesome! of course, I have a demo tomorrow, so think I will grab a snapshot or the source :wink:

If you’re in hurry, you can use the latest nightly build (for the 6.5.6 target), where it’s fixed.

That did the trick, thanks again!