Retrieve dynamic url for files [closed]

asked 2018-06-19 19:27:57 +0800

Ferreiravinicius gravatar image Ferreiravinicius
3 1

I do have some media files coming from database as byte array. How can I retrieve the direct url of this file in ZK ?

I believe that Image component does something like this since it does sets the "src" attribute with a dynamic generated url (but it only works with images).

Just to illustrate what I want to reproduce:

1 - I do have my file being created this way

Media media = new AMedia(myFile.getName(), myFile.getFormat(), null, myFile.getByteArr()); //"myFile" is the object of my entity that holds my file info

2 - I want to retrieve the direct url for my file

getMyUrl(media); //retrieves the path like "/foobar/view/myfile.ext"

Obs: Filedownload.save() does not solve my problem since it doesn't provide any way of retrieving the url instead of just downloading it.

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by cor3000
close date 2018-06-27 10:09:45

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-20 12:19:01 +0800

cor3000 gravatar image cor3000
4466 2 7
ZK Team

updated 2018-06-20 12:22:58 +0800

To generate a media URI that links to your current desktop you can use the method desktop.getDownloadMediaURI(...)

I prepared a simple example illustrating the usage: http://zkfiddle.org/sample/3kt1afe/2-download-media-link

link publish delete flag offensive edit

Question tools

1 follower



Asked: 2018-06-19 19:27:57 +0800

Seen: 10 times

Last updated: Jun 20 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More