PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WM] - Download and save file in Mobile Storage
[WM] - Download and save file in Mobile Storage
Iniciado por guest, 31,mar. 2016 15:34 - 4 respuestas
Publicado el 31,marzo 2016 - 15:34
vello,

I am using following code to download file from web server using HTTPRequest and trying to save it to user selected location on phone. The code runs without any error but the file that gets saved is always of zero (0) byte.

Here is the code snippet that I am using:
nFID is int HTTPRequest("http://xxxxxxxx.com/projects/sa/homework_file/" + gsFileName) sResult is Buffer = HTTPGetResult(httpResult) IF Position(sResult,"404") THEN Info(HTMLToText(sResult)) // or some other error handling to indicate the file was not found ELSE IF Length(sResult) > 0 THEN nFID = fCreate(gsParentPath+gsFileName) IF nFID > 0 THEN Info(fWrite(nFID,sResult,Length(sResult))) END END END Info("File Saved") Close()
Is there any mistake in the code?

Please help me here.

TIA

Yogi Yang
Publicado el 31,marzo 2016 - 16:48
Hi

what is the content of gsParentPath?
Did you try with fSaveBuffer (that's what I'm using)?

Best regards
Publicado el 31,marzo 2016 - 16:53
Oh how stupid of me.

The problem was in this condition:
IF nFID > 0 THEN // <=== This should be : IF nFID >= 0 THEN Info(fWrite(nFID,sResult,Length(sResult))) END
Publicado el 04,abril 2016 - 06:43
Hi Yogi,

>HTTPRequest("http://xxxxxxxx.com/projects/sa/homework_file/" + gsFileName)

Do you need to enable the path under IIS to allow the HTTPRequest to download the file via WM ?

Regards,

PETER ZHOU
Publicado el 04,abril 2016 - 07:38
Hello,

The server from where I have to download the file and save is a Linux Server (CentOS).

TIA

Yogi Yang