On Wed, Mar 29, 2017 at 3:12 PM, Maxim Solodovnik <[email protected]>
wrote:

> Filename is minor issue ....
> Main problem is invalid file :(
>
> How can I serve the file from file system? I thought filesystemreference if
> the best candidate .....
>

If ResourceBehavior#onRequest() is not called then there is no (proper)
Ajax call at all.
So FileSystemResource is not the problem. Something breaks earlier.
I don't have time now to debug it. Later!


>
> WBR, Maxim
> (from mobile, sorry for the typos)
>
> On Mar 29, 2017 8:08 PM, "Sven Meier" <[email protected]> wrote:
>
> > Hi Maxim,
> >
> > three things:
> >
> > - filename ... no one sets the file name :P
> >
> > - serializable error ... FileSystemResource holds a reference to the
> path,
> > which is not serializable
> >
> > - corruct zip ... my bad, it seems that Location.Blob mangles the file on
> > the client side
> >
> > I'll see what I can do about Location.Blob - it might be an encoding
> issue.
> >
> > Have fun
> > Sven
> >
> >
> > On 29.03.2017 14:15, Maxim Solodovnik wrote:
> >
> >> here you are: https://github.com/solomax/ajax-download
> >> Absolutely don't understand what is going on :(
> >>
> >> On Wed, Mar 29, 2017 at 6:30 PM, Maxim Solodovnik <[email protected]
> >
> >> wrote:
> >>
> >>> Yep, zip file is valid
> >>> Breakpoint at AjaxDownload.ResourceBehavior#onRequest() is not hit :(
> >>> Will try to create quickstart
> >>>
> >>> something extremely weird
> >>>
> >>> On Wed, Mar 29, 2017 at 2:22 AM, Martin Grigorov <[email protected]
> >
> >>> wrote:
> >>>
> >>>> Hi Maxim,
> >>>>
> >>>> On Tue, Mar 28, 2017 at 11:06 AM, Maxim Solodovnik <
> >>>> [email protected]>
> >>>> wrote:
> >>>>
> >>>> Thanks a lot Martin for detailed explanation
> >>>>> I do have this functionality working with old version of AjaxDownload
> >>>>>
> >>>>> And here is my first try to migrate to the new internal wicket
> >>>>> AjaxDownload:
> >>>>> https://github.com/apache/openmeetings/commit/
> >>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f
> >>>>>
> >>>>> I would appreciate if you can take a look at this tiny commit.
> >>>>>
> >>>>> Something really doesn't work as expected ....
> >>>>>
> >>>>> Commited version behaves wrong:
> >>>>> 1) file downloaded has wrong name
> >>>>>
> >>>>> You do not set file name anywhere!
> >>>> Keep a reference to the constructed ResourceResponse and call its
> >>>> #setFileName(...)
> >>>>
> >>>>
> >>>> 2) is not valid zip file (cannot be opened)
> >>>>>
> >>>>> Is the backupPath representing a ZIP file ?
> >>>>
> >>>>
> >>>> 3) for some reason I'm not able to get to breakpoint at line 115 [1]
> >>>>>
> >>>>> Put a breakpoint at AjaxDownload.ResourceBehavior#
> onResourceRequested()
> >>>> and
> >>>> see what happens
> >>>>
> >>>>
> >>>> Additionally I got NotSerializable exception in case I made "download"
> >>>>> class final variable
> >>>>>
> >>>>> java.nio.file.Path is not Serializable!
> >>>>
> >>>>
> >>>> What am I doing wrong?
> >>>>>
> >>>>> [1] https://github.com/apache/openmeetings/commit/
> >>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f#diff-
> >>>>> 0a499c88998a93ceb51c347836aa6195R115
> >>>>>
> >>>>> On Thu, Mar 23, 2017 at 3:16 AM, Martin Grigorov <
> [email protected]
> >>>>> >
> >>>>> wrote:
> >>>>>
> >>>>>> On Wed, Mar 22, 2017 at 12:59 PM, Maxim Solodovnik <
> >>>>>> [email protected]
> >>>>>>
> >>>>>> wrote:
> >>>>>>
> >>>>>> Actually I have 2 example use cases:
> >>>>>>>
> >>>>>>> 1) user selects files on file tree
> >>>>>>> 2) as soon as file is selected and download is enabled for it, used
> >>>>>>> can
> >>>>>>> press ajax download button and get the file
> >>>>>>>
> >>>>>>> Another case:
> >>>>>>> User requests system backup
> >>>>>>> As soon as backup is created (Progress complete)
> >>>>>>> Download of newly created file should be initiated
> >>>>>>>
> >>>>>>> I can't create ResourceReference and override getResourceStream of
> it
> >>>>>>>
> >>>>>> since
> >>>>>
> >>>>>> I only have resource just before download
> >>>>>>>
> >>>>>>> Wicket IResource is an abstraction over the real resource.
> >>>>>> In my case i also create the response on the fly. It is either a
> >>>>>> single
> >>>>>> File or a Zip file with several entries.
> >>>>>> The ResourceReference is more or less just an endpoint with almost
> no
> >>>>>>
> >>>>> logic
> >>>>>
> >>>>>> at all. It just creates the IResource.
> >>>>>> The IResource uses the information from the request parameters /
> >>>>>> session
> >>>>>>
> >>>>> /
> >>>>>
> >>>>>> somewhere else to create the actual response (the files).
> >>>>>>
> >>>>>> AjaxDownload is an Ajax behavior that you can use to trigger the
> >>>>>> creation
> >>>>>> of the files and by using its callback methods you can show feedback
> >>>>>> to
> >>>>>>
> >>>>> the
> >>>>>
> >>>>>> user. To show progress bar you will need to employ ProgressBar from
> >>>>>> wicket-extentions or use WebSockets.
> >>>>>>
> >>>>>>
> >>>>>> On Wed, Mar 22, 2017 at 6:53 PM, Martin Grigorov <
> >>>>>>> [email protected]>
> >>>>>>> wrote:
> >>>>>>>
> >>>>>>> Hi Maxim,
> >>>>>>>>
> >>>>>>>> I use the new AjaxDownload with a ResourceReference, i.e.
> >>>>>>>> AjaxDownload#AjaxDownload(org.apache.wicket.request.
> >>>>>>>> resource.ResourceReference,
> >>>>>>>> org.apache.wicket.request.mapper.parameter.PageParameters)
> >>>>>>>> The ResourceReference has
> >>>>>>>>
> >>>>>>>> public IResource getResource() {
> >>>>>>>>      return new StatementDownloadResource();
> >>>>>>>> }
> >>>>>>>>
> >>>>>>>> StatementDownloadResource extends ResourceStreamResource and
> >>>>>>>> provides
> >>>>>>>> implementation of #getResourceStream(). There I have a logic that
> >>>>>>>>
> >>>>>>> returns
> >>>>>
> >>>>>> either FileResourceStream or ZipResourceStream.
> >>>>>>>>
> >>>>>>>> Martin Grigorov
> >>>>>>>> Wicket Training and Consulting
> >>>>>>>> https://twitter.com/mtgrigorov
> >>>>>>>>
> >>>>>>>> On Wed, Mar 22, 2017 at 12:30 PM, Maxim Solodovnik <
> >>>>>>>>
> >>>>>>> [email protected]
> >>>>>
> >>>>>> wrote:
> >>>>>>>>
> >>>>>>>> Just have tried to switch to this AjaxDownload component
> >>>>>>>>> And it seems I cannot find proper way to use it with dynamic
> file,
> >>>>>>>>>
> >>>>>>>> i.e.
> >>>>>
> >>>>>> previously
> >>>>>>>>> I created AjaxDownload,
> >>>>>>>>> added it to the page
> >>>>>>>>> then at the moment I know what file should be served, I set the
> >>>>>>>>>
> >>>>>>>> stream
> >>>>>
> >>>>>> and
> >>>>>>>>
> >>>>>>>>> initiate the download
> >>>>>>>>> (for example one of use cases: I need to create zip file
> >>>>>>>>>
> >>>>>>>>> right now this seems to be impossible :(
> >>>>>>>>> Can you give me a hint how this dynamic nature can be
> implemented?
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> --
> >>>>>>>>> WBR
> >>>>>>>>> Maxim aka solomax
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>
> >>>>>>> --
> >>>>>>> WBR
> >>>>>>> Maxim aka solomax
> >>>>>>>
> >>>>>>>
> >>>>>
> >>>>> --
> >>>>> WBR
> >>>>> Maxim aka solomax
> >>>>>
> >>>>>
> >>>
> >>> --
> >>> WBR
> >>> Maxim aka solomax
> >>>
> >>
> >>
> >>
> >
>

Reply via email to