hereForLearing
hereForLearing

Reputation: 1298

What's the recommended way to display image from ftp server in grails?

Which one of the following ways is more "proper" to display an image from ftp in a gsp view, I need images to be only displayable for specific users, in the both following ways I will use a controller to check the user identity before passing the requested image:
1)Retrieve the image from the ftp server and put it in a temp file then pass the image link to the view.
2)Retrieve the image and transfer it as bytes to the view, is it possible to show image from bytes only using html/grails?
or there is a better way ?
Thank you

Upvotes: 0

Views: 623

Answers (1)

Robert Moskal
Robert Moskal

Reputation: 22553

Sure. You can render in InputStream from grails.

It's an extra step to create a file from the ftp download. But rendering an image from an InputStream will require an extra endpoint to be rendered. So I'd say it's a wash in terms of effort. Neither is preferable in terms is style.

If you download the image as a file, depending on your needs, you can avoid subsequent ftp downloads of your image. You can just serve the downloaded file locally instead of continually refetching it from the the ftp server.

If you always need a fresh copy of the image then you should just serve the image from the FtpClient.

Upvotes: 1

Related Questions