Page 1 of 1

OnSaveFile

PostPosted: 23 Apr 2017 06:29
by etwoss
Hi

This event is added on request to stop uploading a file if , for some reason, you don't want to uplod is, for example if it already exists.

However the param "ATempPathName" hold a value like "'C:\Users\ADMINI~1\AppData\Local\Temp\01b8pv0gwr\ATZ35DF5FB18825.tmp" where the filename is "Boost.txt" and if i set the param "AHandled" to true of false, the file is still in UploadOptionsComplete event.

Added 24-2-2017:
Just checked the sourcecode:
Code: Select all
    LIsHanlded:= False;
    if Assigned(FOnSaveFile) then
      FOnSaveFile(Self,LFile.TempPathName,LIsHanlded);



So the "LFile.TempPathName" is what i get, where i need "Filename"
if AHandled = True, the file is not saved, which i tested and works fine

However i don't expect the file be present in the list of uploaded files in the UploadOptionsComplete event.

Also the file is made visible ( A set Handled to true for B4.png) so i don't expect that one to show up.



Eric

Re: OnSaveFile

PostPosted: 24 Apr 2017 07:45
by etwoss
Hi

Second question

In the event, i check if the file already exists, if so i need to ask the User if he wants to overwrite the file, if no, the file should not get uploaded.
However showing a confirmation dialog is not the correct way because the OnSave event had ended already before the dialog is shown.

How to handle this situation?

Eric

Re: OnSaveFile

PostPosted: 26 Apr 2017 15:50
by Alexander Bulei
Hi Eric,

So the "LFile.TempPathName" is what i get, where i need "Filename"
if AHandled = True, the file is not saved, which i tested and works fine


I have added new event OnSaveEx..available in next beta build(s).

However i don't expect the file be present in the list of uploaded files in the UploadOptionsComplete event.

Also the file is made visible ( A set Handled to true for B4.png) so i don't expect that one to show up.


Use the Exception to avoid this behavior.

Best Regards.

Re: OnSaveFile

PostPosted: 27 Apr 2017 06:42
by etwoss
Hi

Installed 218

Should the SaveEx be there?

What do you mean , use an exception?
Hrow an exception as the users answers no in the confirmation dialog?

Eric

Re: OnSaveFile

PostPosted: 02 May 2017 09:37
by Alexander Bulei
Hi Eric,

Installed 218

Should the SaveEx be there?


This event is available since 3.0.0.219
What do you mean , use an exception?


delphi code
raise Exception.Create('File already exists!');


Hrow an exception as the users answers no in the confirmation dialog?


I will check if it possible.

Best Regards.

Re: OnSaveFile

PostPosted: 12 Jul 2017 09:52
by etwoss
Hi

Never had an answer

Eric

Re: OnSaveFile

PostPosted: 04 Sep 2017 10:28
by etwoss
Hi

Still no answer?

Eric

Re: OnSaveFile

PostPosted: 06 Sep 2017 15:05
by Jorge Sousa
Hi Eric

This is a good a idea, but unfortunatelly,
You can't use the OnFileSave, OnFileSaveEx, OnGetFileName to perform any visual changes including a verification message.

Currently the only is if you check if the file exists in OnGetFileName, if it exists set a flag, give it an temp unique name, and in JQUploadOptions.OnComplete, if exists then you can ask the user so that you can delete and rename the temp file if user says yes, or just delete the temp file if it says no.

Of course that a file will be download whether wants to overwrite it or not :/

Re: OnSaveFile

PostPosted: 06 Sep 2017 15:28
by etwoss
Hi

Good solution

Thanks

Eric