FoxInCloud
wFileSaveAs - Delete file
Gravatar is a globally recognized avatar based on your email address. wFileSaveAs - Delete file
  Vincent H.
  All
  Jun 26, 2021 @ 01:22am

Hi Thierry,

wFileSaveAs again ...

Viewing a recently created pdf file deletes it (move to \ Temp)

Description: I create a PDF file with a report form ... to file ... then I visualize this file with wFileSaveAs (MyFile.pdf), Myfile.pdf is systematically deleted from its original location.

Workaround: introduce a delay of at least 3 seconds.
In this case, viewing no longer deletes my PDF

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  FoxInCloud Support - Thierry N.
  Vincent H.
  Jun 26, 2021 @ 03:20am

Hi Vincent

IIRC, we added a parameter to cope with this case…

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  Vincent H.
  FoxInCloud Support - Thierry N.
  Jun 26, 2021 @ 04:42am

The extra parameter was to add a timestamp so as to bypass the cache memory ...

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  Vincent H.
  Vincent H.
  Jun 27, 2021 @ 12:25am

awserver.prg

PROCEDURE DownloadFile && {fr} Envoie un fichier à l'utilisateur pour qu'il décide quoi en faire : l'ouvrir ou l'enregistrer
LPARAMETERS ;
  tcFile; && {fr} Fichier {en} File
, tcResult; && @ [''] {fr} Résultat en retour {en} Result back
, tlFileKeep; && [.F.] {fr} conserver le fichier original {en} keep original file after copy to site's temp folder
, tcWindow; && [''] {fr} Nom de la fenêtre de navigateur où ouvrir le fichier si le navigateur est capable de l'afficher {en} Name of the browser window where file can possibly be displayed
, tlTemp; && [.F.] {en} Temporary file: add time stamp to file stem {fr} Fichier temporaire : ajouter la date-heure à la racine du fichier && 2020-09-01 thn -- {FiC V 2.31.0-beta.5} {en} added 

tlFileKeep = .T. fixes the problem, but to my knowledge, this parameter is not accessible from wFileSaveAs()

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  FoxInCloud Support - Thierry N.
  Vincent H.
  Jun 27, 2021 @ 11:17am

Right, we probably overlooked this parameter

modify class awfrm of aw method wFileSaveAs

lparameters tcFileSrce, tcResult, tcWindow, tlTemp, tlFileKeep && see parameter doc in awFrm code

&& 1- tcFileSrce {en} File to Save As {fr} Fichier à envoyer à l'utilisateur
&& 2- tcResult @ [''] {en} File saved by user (LAN) or error (Web) {fr} Fichier choisi par l'utilisateur (LAN) ou erreur (Web)
&& 3- tcWindow [''] {en} Name of the browser window where file can possibly be displayed {fr} Nom de la fenêtre de navigateur où ouvrir le fichier si le navigateur est capable de l'afficher (added 2016-02-04)
&& 4- tlTemp [.F.] {en} Temporary file: add time stamp to file stem {fr} Fichier temporaire : ajouter la date-heure à la racine du fichier && 2020-09-01 thn -- {FiC V 2.31.0-beta.5} {en} added 
&& 5- tlFileKeep && [.F.] (Web) {en} keep original file after copy to site's temp folder {fr} conserver le fichier original  && 2021-06-27 thn -- {FiC V 2.31.1-beta.1} {en} added

tcResult = ''

LOCAL success;
, lcFileSrce;
, lcFileDest;
, oAJAX as awAJAX of awServer.prg;

success = Vartype(m.tcFileSrce) == 'C' AND File(m.tcFileSrce)
tcResult = Iif(m.success, m.tcResult, Textmerge(ICase(;
	cLangUser() = 'fr', 	[Le Fichier <<cLitteral(m.tcFileSrce)>> est introuvable],; && copy-paste this line to add another language support
												[File <<cLitteral(m.tcFileSrce)>> can't be found]; && default: English
	)))
ASSERT m.success MESSAGE cAssertMsg(m.tcResult)

DO CASE
CASE !m.success
CASE wlAJAX(@m.oAJAX) && Web mode
	
	success = m.oAJAX.DownloadFile(;
		  m.tcFileSrce; && {fr} Fichier {en} File
		,@m.tcResult;  && @ [''] {fr} {en} Result back Résultat en retour
		, m.tlFileKeep; && [.F.] {en} keep original file after copy to site's temp folder {fr} conserver le fichier original
		, m.tcWindow;  && [''] {en} Name of the browser window where file can possibly be displayed {fr} Nom de la fenêtre de navigateur où ouvrir le fichier si le navigateur est capable de l'afficher
		, m.tlTemp;   && [.F.] {en} Temporary file: add time stamp to file stem {fr} Fichier temporaire : ajouter la date-heure à la racine du fichier && 2020-09-01 thn -- {FiC V 2.31.0-beta.5} {en} added 
		)

OTHERWISE

	tcFileSrce = cFileCased(m.tcFileSrce, .T.)

	lcFileDest = this.wPutFile(;
		  JustFname(m.tcFileSrce);
		, ForcePath(m.tcFileSrce, cSpecialFolderPath(CSIDL_PERSONAL)); && 'my documents' - modify file abFile.h
		, JustExt(m.tcFileSrce);
		)
	IF Empty(m.lcFileDest) or m.lcFileDest == FullPath(m.tcFileSrce)

		tcResult = m.tcFileSrce

	ELSE
	
		* {fr} Si le fichier peut être copié vers l'emplacement demandé
		success = FileCopy(m.tcFileSrce, m.lcFileDest, @m.tcResult)
		tcResult = Iif(m.success, m.tcResult, Textmerge(ICase(;
			cLangUser() = 'fr', 	[Erreur en copiant le fichier '<<DisplayPath(m.tcFileSrce, 50)>>' vers '<<DisplayPath(m.lcFileDest, 50)>>' : ],; && copy-paste this line to add another language support
														[Error while copying file '<<DisplayPath(m.tcFileSrce, 50)>>' to '<<DisplayPath(m.lcFileDest, 50)>>': ]; && default: English
		)) + m.tcResult)
		ASSERT m.success MESSAGE cAssertMsg(m.tcResult)
		IF m.success
		
			* {fr} Si fichier temporaire, supprimer
			IF lTrue(m.tlTemp) or Datetime() - Fdate(m.tcFileSrce, 1) < 2 && {fr} fichier créé depuis moins de 2 secondes, temporaire
				success = FileDel(m.tcFileSrce,,, @m.tcResult) && {fr} FileDelete() abandonné à cause d'un conflit avec FileDelete.exe de web connect
			ENDIF
			IF m.success

				tcResult = m.lcFileDest
			ENDIF
		ENDIF
	ENDIF
ENDCASE

RETURN m.success
Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  Vincent H.
  FoxInCloud Support - Thierry N.
  Jun 28, 2021 @ 12:53am

OK, thanks.
When do you plan to release the V 2.31.1-beta.1 ?

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  Vincent H.
  Vincent H.
  Jun 28, 2021 @ 01:02am

Tested. This works fine !

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  Vincent H.
  Vincent H.
  Jun 28, 2021 @ 01:17am

Just a(nother) question: in what context can we fill tcResult ?

Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  FoxInCloud Support - Thierry N.
  Vincent H.
  Jun 28, 2021 @ 02:16am

tcResult is the result provided back by the function, an error if any, reason why you pass this parameter by reference (@ in the description below)

&& 2- tcResult @ [''] {en} File saved by user (LAN) or error (Web) {fr} Fichier choisi par l'utilisateur (LAN) ou erreur (Web)
Gravatar is a globally recognized avatar based on your email address. re: wFileSaveAs - Delete file
  FoxInCloud Support - Thierry N.
  Vincent H.
  Jun 28, 2021 @ 06:23am

When do you plan to release the V 2.31.1-beta.1 ?

Hopefully this week

© 1996-2021